[Nauty] Warning when compiling in C++

Jerry James loganjerry at gmail.com
Sun Feb 16 02:01:18 AEDT 2025


On Sat, Feb 15, 2025 at 3:34 AM Mathieu Dutour via Nauty
<nauty at anu.edu.au> wrote:
> When compiling a C++17 program that uses nauty I have the
> following warning message:
> gtools.h:305:13: warning: unknown attribute '_Noreturn' ignored
> [-Wunknown-attributes]
>   305 | extern void NORET_ATTR gt_abort(const char*);
>       |             ^~~~~~~~~~
> nauty.h:61:22: note: expanded from macro 'NORET_ATTR'
>    61 | #define NORET_ATTR [[_Noreturn]]
>
>
> The attribute [[noreturn]] is defined in C++11:
> https://en.cppreference.com/w/cpp/language/attributes/noreturn
> For C, this is from C23.

Drat, I thought I researched this carefully when I suggested the
current form.  You are correct.

> So, the correct writing for the definition is:
> /* Function noreturn attribute, if any */
> #define C_NORET_ATTR _Noreturn   /* Only for C */
> #if (defined(__cplusplus) && __cplusplus >= 201102L) \
>         || (!defined(__cplusplus) && __STDC_VERSION__ >= 202311L)
> #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

I think "__cplusplus >= 201102L" should be "__cplusplus >= 201103L"
instead, but otherwise that looks correct to me.  However, I don't
understand the need for the C_NORET_ATTR macro.  That code sets
NORET_ATTR appropriately for C.

> However, the file "nauty.h" is created by the configure script.
> So, the corrections would have to be there. But it is unclear
> to me how to do this yet.

You need to patch nauty-h.in.  The configure script uses that to create nauty.h.
-- 
Jerry James
http://www.jamezone.org/



More information about the Nauty mailing list