Skip to content
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

-Wundef when building with g++ -std=c++20 #84

Closed
simark opened this issue Apr 29, 2024 · 0 comments · May be fixed by #85
Closed

-Wundef when building with g++ -std=c++20 #84

simark opened this issue Apr 29, 2024 · 0 comments · May be fixed by #85

Comments

@simark
Copy link

simark commented Apr 29, 2024

Using master as of today, I get:

$ g++ -x c++-header span.hpp -Wundef -Werror -std=c++20 
span.hpp:43:33: error: "span_HAVE_STRUCT_BINDING" is not defined, evaluates to 0 [-Werror=undef]
   43 | #define span_HAVE( feature )  ( span_HAVE_##feature )
      |                                 ^~~~~~~~~~
span.hpp:1873:5: note: in expansion of macro ‘span_HAVE’
 1873 | #if span_HAVE( STRUCT_BINDING )
      |     ^~~~~~~~~
cc1plus: all warnings being treated as errors         
simark added a commit to simark/span-lite that referenced this issue May 6, 2024
When including `span.hpp` in a source file compiled as C++20, I get an
error similar to this:

    $ g++ -x c++-header span.hpp -Wundef -Werror -std=c++20
    span.hpp:43:33: error: "span_HAVE_STRUCT_BINDING" is not defined, evaluates to 0 [-Werror=undef]
       43 | #define span_HAVE( feature )  ( span_HAVE_##feature )
          |                                 ^~~~~~~~~~
    span.hpp:1873:5: note: in expansion of macro ‘span_HAVE’
     1873 | #if span_HAVE( STRUCT_BINDING )
          |     ^~~~~~~~~

Fix it by checking if `span_HAVE_STRUCT_BINDING` is defined.  This
Unfortunately, I couldn't find a way to make `defined()` work with
`span_HAVE( STRUCT_BINDING )`.

An alternative would be to move the definition of
`span_HAVE_STRUCT_BINDING` outside of the `span_USES_STD_SPAN` ifdef.

Fixes martinmoene#84.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
simark added a commit to simark/span-lite that referenced this issue May 6, 2024
When including `span.hpp` in a source file compiled as C++20, I get an
error similar to this:

    $ g++ -x c++-header span.hpp -Wundef -Werror -std=c++20
    span.hpp:43:33: error: "span_HAVE_STRUCT_BINDING" is not defined, evaluates to 0 [-Werror=undef]
       43 | #define span_HAVE( feature )  ( span_HAVE_##feature )
          |                                 ^~~~~~~~~~
    span.hpp:1873:5: note: in expansion of macro ‘span_HAVE’
     1873 | #if span_HAVE( STRUCT_BINDING )
          |     ^~~~~~~~~

Fix it by checking if `span_HAVE_STRUCT_BINDING` is defined.
Unfortunately, I couldn't find a way to make `defined()` work with
`span_HAVE( STRUCT_BINDING )`.

An alternative would be to move the definition of
`span_HAVE_STRUCT_BINDING` outside of the `span_USES_STD_SPAN` ifdef.

Fixes martinmoene#84.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant