Which header defines the macro that specifies the machine architecture?

No header file defines it - those macros are predefined by the compiler. To find out the full list of predefined macros do this:

echo | gcc -E -dM -

Then look through the results for likely macros.


More precisely, I think this is where the __x86_64__ is defined for example: https://github.com/gcc-mirror/gcc/blob/releases%2Fgcc-10.2.0/gcc/config/i386/i386-c.c#L688

 cpp_define (parse_in, "__x86_64__");

but I didn't have the patience to modify the source, recompile and test it out yet. A good way to search is:

git grep '"__aarch64__'