> Author: imp > Date: Fri Aug 25 04:33:06 2017 > New Revision: 322875 > URL: > https://svnweb.freebsd.org/changeset/base/322875 > > > Log: > Use _Static_assert > > These files are compiled in userland too, so we can't use sys/systm.h > and rely on CTASSERT. Switch to using _Static_assert instead. > > MFC After: 3 days > Sponsored by: Netflix > > Modified: > head/sys/dev/nvme/nvme.h > head/sys/dev/nvme/nvme_util.c
As I remember _Static_assert is from C11, not the older C99. As I understand head/sys/dev/nvme/nvme.h use by C++ code could now reject attempts to use _Static_assert . There have been at least one old bugzilla report for such. An example is 205453 (back around 2015-Dec). >From back then: > # more main.cc > #include "/usr/include/sys/cdefs.h" > _Static_assert(1,"Test"); > int main(void) > { > return 0; > } > > For example: > > # g++49 main.cc > main.cc:2:15: error: expected constructor, destructor, or type conversion > before '(' token > _Static_assert(1,"Test"); > . . . > g++49, g++5, and powerpc64-portbld-freebsd11.0-g++ all reject the above > source the same way that libcxxrt/guard.cc compiles are rejected during > powerpc64-portbld-freebsd11.0-g++ based buildworld lib32 -m32 compiles. > > gcc49, gcc5, and powerpc64-portbld-freebsd11.0-gcc all accept the above > instead (when in main.c instead of main.cc so it is handle as C code), with > or without the include. _Static_assert is specific to C11 and is not part of > C++. It takes explicit definitions to make the syntax acceptable as C++. > > Note: clang++ (3.7) accepts the use of the C11 _Static_assert, with or > without the include, going well outside the C++ language definition. > > . . . > > Fixed in r297299 . (The context was a C++ file head/contrib/libcxxrt/guard.cc so C++'s static_assert was used instead and -std=c++11 was added for the library in question [libcxxrt].) Unless head/sys/dev/nvme/nvme.h is not to be used from C++ code: use of _Static_assert in the header would appear to be a problem. === Mark Millard markmi at dsl-only.net _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"