On 07.02.22 20:24, Andres Freund wrote:
To be honest, I do not really understand the logic behind when autoconf ends
up with #defines that define a macro to 0/1 and when a macro ends defined/or
not and when we end up with a macro defined to 1 or not defined at all.

The default is to define to 1 or not at all. The reason for this is presumably that originally, autoconf (or its predecessor practices) just populated the command line with a few -DHAVE_THIS options. Creating a header file came later. And -DFOO is equivalent to #define FOO 1. Also, this behavior allows code to use both the #ifdef HAVE_THIS and the #if HAVE_THIS style.

The cases that deviate from this have a special reason for this. One issue to consider is that depending on how the configure script is set up or structured, a test might not run at all. But for example, if you have a check for a declaration of a function, and the test doesn't run in a particular configuration, the fallback in your own code would normally be to then manually declare the function yourself. But if you didn't even run the test, then adding a declaration of a function you didn't want in the first place might be bad. In that case, you can check with #ifdef whether the test was run, and then check the value of the macro for the test outcome.


Reply via email to