On 24.03.2022 17:42, Bob Friesenhahn wrote:
On Thu, 24 Mar 2022, Evgeny Grin wrote:It's not uncommon to use CFLAGS for macros or for '-I' flags.I think it's easy to imagine other conflicting situation where the order of used flags is significant.It may not be uncommon, but it is a usage bug to use CFLAGS for pre-processor options. Such usages should be corrected.
I can't fully agree. First of all, portable build cannot rely of CPPFLAGS support as POSIX doesn't define it. See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html#tag_20_76_13_09 Secondly, there are too many situations, where pre-processor flags considered as a part of set of compiler flags, like https://people.freedesktop.org/~dbn/pkg-config-guide.html#concepts
Maybe we can try to fix them all, but it looks impractical.
Becides cases where the pre-processor may be used directly (not sure if there are any), it should be considered that CPPFLAGS works for both the C and C++ compilers but CFLAGS is only for the C compiler.
I can see the only one situation, where pre-processor flags could be used directly: it is tests inside "configure". However, the more reliable way to test is to use compile-test instead of pure pre-processor test. So the direct use is really quite limited.
Without a doubt, CPPFLAGS are different in purpose. The question is how to combine them with CFLAGS in proper and portable way.
Usage of CPPFLAGS before CFLAGS looks logical for me, I think autoconf should be fixed.It does feel more logical.
While it looks more logical, it can be suboptimal and not aligned with other tools.
-- Evgeny
Attachment:
OpenPGP_0x460A317C3326D2AE.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature
Description: OpenPGP digital signature