[Nauty] Compilation issue with g++: Change "_Noreturn" to "__attribute__((__noreturn__))"

Brendan McKay Brendan.McKay at anu.edu.au
Thu Jul 18 22:36:34 AEST 2024


Hi Lluís,

In the development version of nauty not yet released, nauty-h.in has this
code sent by Jerry James:

/* Function noreturn attribute, if any */
#if (defined(__cplusplus) && __cplusplus >= 202302L) \
         || (!defined(__cplusplus) && __STDC_VERSION__ >= 202311L)
#define NORET_ATTR [[noreturn]]
#elif defined(__cplusplus) && __cplusplus >= 201103L
#define NORET_ATTR [[_Noreturn]]
#elif !defined(__cplusplus) && __STDC_VERSION__ >= 201112L
#define NORET_ATTR _Noreturn
#elif defined(__GNUC__)
#define NORET_ATTR __attribute__((noreturn))
#elif defined(_MSC_VER)
#define NORET_ATTR __desclspec(noreturn)
#else
#define NORET_ATTR
#endif

If you make that change and run ./configure again, it should compile 
properly.

Please let me know if you still have problems.

Cheers, Brendan.

On 18/7/2024 9:16 pm, Lluís Alemany Puig via Nauty wrote:
> Hello,
>
> I've just updated my version of nauty from 2_8_6 to 2_8_8 in my C++ 
> project and it no longer compiles. The issue is due to the attribute 
> _Noreturn (used to define NORET_ATTR and, in turn used to define 
> gt_abort) which is not part of the C++ standard and g++ (version 
> 11.4.0) does not accept it. I changed the definition of NORET_ATTR in 
> nauty.h from
>
>    #define NORET_ATTR _Noreturn
>
> to
>
>    #define NORET_ATTR __attribute__((__noreturn__))
>
> and now g++ no longer complains. These two definitions are equivalent 
> (see this question 
> <https://stackoverflow.com/questions/28552467/is-there-a-way-to-use-gcc-attribute-noreturn-and-stdnoreturn-h-sanely-i 
> in stackoverflow). ChatGPT tells me that as long as I use -std=c++17 
> (or some other standard newer than C++11, which I already do) the code 
> should compile, but I could not get it to work this way. Maybe 
> _Noreturn clashes with some other necessary flag that I use in my 
> project.
>
> I would like to ask nauty's developers to change '_Noreturn' to 
> '__attribute__((__noreturn__))' all C++ programmers out there who use 
> Nauty.
>
> Best,
>
> Lluís
> _______________________________________________
> Nauty mailing list
> Nauty at anu.edu.au
> https://mailman.anu.edu.au/mailman/listinfo/nauty


More information about the Nauty mailing list