Closed gemesa closed 11 months ago
Thanks, merged but modified because gcc should be on first rank.
That would have been my preference also but with this approach we are back to the original problem because __GNUC__
is defined both by gcc
and clang
so the branch #elif defined(__clang__)
is never hit. If you want to check for __GNUC__
first, you could write something like this:
#if defined(__GNUC__) && !defined(__clang__)
fprintf(stdout, "compiled by gcc %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#elif defined(__clang__)
fprintf(stdout, "compiled by clang %d.%d.%d\n", __clang_major__, __clang_minor__, __clang_patchlevel__);
...
Thanks, that is better:
$ ./hcxdumptool -v
hcxdumptool 6.3.2-145-g4fd4dfb (C) 2023 ZeroBeat
running on Linux kernel 6.6.7-arch1-1
running GNU libc version 2.38
compiled by gcc 13.2.1
compiled with Linux API headers 6.4.0
compiled with GNU libc headers 2.38
enabled REALTIME DISPLAY
enabled GPS support
enabled BPF compiler
$ ./hcxdumptool -v
hcxdumptool 6.3.2-145-g4fd4dfb (C) 2023 ZeroBeat
running on Linux kernel 6.6.7-arch1-1
running GNU libc version 2.38
compiled by clang 16.0.6
compiled with Linux API headers 6.4.0
compiled with GNU libc headers 2.38
enabled REALTIME DISPLAY
enabled GPS support
enabled BPF compiler
Previously when compiled with
clang
the version check returned this misleadinggcc
version:I guess it is because
clang
defines the__GNUC__
macros for some compatibility reasons or something like that.I think
clang
is becoming more widespread so this case should be handled. Now, after the changes the version check is fixed: