Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbaf7c93

Browse files
committed
Define unconstify() and unvolatize() for C++.
These two macros wouldn't work if used in an inline function definitionin a header seen by g++, because __builtin_types_compatible_p is onlyavailable in C. Redirect to standard C++ const_cast (which alsoadds/removes volatile despite its name).Per cpluspluscheck failure in a development branch.Suggested-by: Peter Eisentraut <peter@eisentraut.org>Discussion:https://postgr.es/m/CA%2BhUKGK3OXFjkOyZiw-DgL2bUqk9by1uGuCnViJX786W%2BfyDSw%40mail.gmail.com
1 parent0a5c46a commitbaf7c93

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

‎src/include/c.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,10 @@ typedef union PGAlignedXLogBlock
12451245
* Note that this only works in function scope, not for global variables (it'd
12461246
* be nice, but not trivial, to improve that).
12471247
*/
1248-
#if defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P)
1248+
#if defined(__cplusplus)
1249+
#defineunconstify(underlying_type,expr) const_cast<underlying_type>(expr)
1250+
#defineunvolatize(underlying_type,expr) const_cast<underlying_type>(expr)
1251+
#elif defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P)
12491252
#defineunconstify(underlying_type,expr) \
12501253
(StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \
12511254
"wrong cast"), \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp