-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix ZEND_STATIC_ASSERT for -std=c++17 #19175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a C++ person, but looks correct to me.
Merge with be09985. Thanks ! |
|
||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */ | ||
#if defined(__cplusplus) | ||
# define ZEND_STATIC_ASSERT(c, m) static_assert((c), m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@psumbera @devnexen static_assert()
was added in C++11 so this change breaks compilation with -std=c++98
(e.g. swig/swig#3255). If you're going to use static_assert()
with C++, it should only be for C++11 and later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we did not put guards because php supports now C++11/17 minimum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
honestly, if you have the choice, please drop C++98, std::move avoiding better dangling pointers is really worth the jump and that s not the only benefit ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that also a requirement when building a third party extension module written in C++? That's the situation where we hit this (rather than when building PHP itself as in the linked issue).
If so, where is this requirement documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not documented per say but PHP had updated the C++ build here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly I don't really have the choice (though personally I tend to agree). SWIG is a tool to generate bindings for various langauges, including PHP, and those bindings are very widely used so we're pretty conservative on raising such requirements.
I can argue for raising it specifically for SWIG/PHP if PHP itself rejects compiling with older C++ versions, though it'd be easier to argue if this requirement were documented properly, and also useful to know how evolves with each PHP version. I'd think documenting this would also be helpful for other users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes good point about documenting
Fixes: #19169