jarro2783 / cxxopts

Lightweight C++ command line option parser
MIT License
4.25k stars 590 forks source link

GCC-12 `error: standard attributes in middle of decl-specifiers` #353

Closed sizeak closed 2 years ago

sizeak commented 2 years ago

When compiling with GCC 12, I get the following error:

error: standard attributes in middle of decl-specifiers
   68 | #define CXXOPTS_NODISCARD [[nodiscard]]
ilyapopov commented 2 years ago

I am getting the same on GCC 11 (however only as warning):

external/cxxopts/include/cxxopts.hpp:68:27: note: an attribute that appertains to a type-specifier is ignored
   68 | #define CXXOPTS_NODISCARD [[nodiscard]]
      |                           ^
external/cxxopts/include/cxxopts.hpp:1252:1: note: in expansion of macro ‘CXXOPTS_NODISCARD’
 1252 | CXXOPTS_NODISCARD
      | ^~~~~~~~~~~~~~~~~

the offending line is this: https://github.com/jarro2783/cxxopts/blob/e976f964c3ee6a4f6faa836ecb38f3ff8b043114/include/cxxopts.hpp#L1251-L1254

ilyapopov commented 2 years ago

Update: moving CXXOPTS_NODISCARD before inline helps.

jarro2783 commented 2 years ago

I'll take a look at this.

jarro2783 commented 2 years ago

I wonder why I don't see this, are there any unusual flags that you are using?

jarro2783 commented 2 years ago

Oh it's a C++17 thing. Pushing a fix now.

sizeak commented 2 years ago

Thanks for the fast response!