[Nauty] nauty and Traces in modern C++
Brendan McKay
Brendan.McKay at anu.edu.au
Sat Feb 10 11:47:04 AEDT 2024
Hi Johann,
You need the macros, but you can adjust the meaning in some cases.
First, make sure your code is reading the correct nauty.h.
The meaning of NORET_ATTR is chosen by the configure script. In the case
of a modern C compiler (*), it will be defined as _Noreturn which is a
function
attribute specifying that the function never returns (in this case
because it
always calls exit()). It helps optimization.
My guess is that your C++ compiler doesn't understand _Noreturn, so the
declaration
of gt_abort is deemed invalid and then everything that uses gt_abort is
rejected as well; DYNALLOC1 in this case.
You can try selecting a more recent C++ version in your build instructions.
If all else fails, find this line in nauty-h.in:
#define NORET_ATTR @ac_cv_noret@
and replace if by:
#define NORET_ATTR
Then run ./configure again. Lots of people use nauty in C++, though I am
not one of them.
I can modify the code to disable _Noreturn in the event of C++ compilation,
but if anyone else has suggestions about this I'd like to hear them.
Brendan.
(*) I read on the web that _Noreturn was introduced in C11, but it is
present in
my copy of the C99 standard. Was it dropped at the last minute, perhaps?
On 10/2/2024 11:01 am, Johann Birnick via Nauty wrote:
> Hello,
>
> I want to use nauty and Traces in a modern C++ project, which uses
> CMake for building. How to do that appropriately? In particular:
>
> 1. In my current setup, when I want to run an example from the
> documentation, I get the following error:
>
> /usr/include/nauty/gtools.h:302:24: error: expected initializer
> before ‘gt_abort’
> 302 | extern void NORET_ATTR gt_abort(const char*);
> | ^~~~~~~~
> /home/johann/Coding/MabreSolve/main.cpp: In function ‘int main()’:
> /home/johann/Coding/MabreSolve/main.cpp:31:13: error: ‘gt_abort’ was
> not declared in this scope; did you mean ‘gt_abort_1’?
> 31 | DYNALLOC1(int, lab1, lab1_sz, n, "malloc");
> | ^~~~~~~~~
>
> Do you have any idea what's the problem and how to fix it?
>
> 2. I guess in modern C++ one shouldn't use all these in capital letters
> written macros and global variables (DYNALLOC1, SG_ALLOC,
> NAUTYVERSIONID, and so on). Is there a way to do this the 'modern
> way'?
>
> Thank you very much in advance!
>
> Johann B.
> _______________________________________________
> Nauty mailing list
> Nauty at anu.edu.au
> https://mailman.anu.edu.au/mailman/listinfo/nauty
More information about the Nauty
mailing list