[Nauty] Warning when compiling in C++
Mathieu Dutour
mathieu.dutour at gmail.com
Sat Feb 15 21:23:35 AEDT 2025
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.
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
and the definitions are:
NORET_ATTR extern void alloc_error(const char*);
and (in gtools.h)
NORET_ATTR extern void gt_abort(const char*);
With those corrections, the C-code compiles without warning
and the C++17 program compiles without warning.
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.
Mathieu
More information about the Nauty
mailing list