https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113152
--- Comment #17 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Mon, Jan 22, 2024 at 05:35:41PM +0000, anlauf at gcc dot gnu.org wrote: > --- Comment #16 from anlauf at gcc dot gnu.org --- > (In reply to Steve Kargl from comment #14) > > On Sun, Jan 21, 2024 at 09:52:39PM +0000, anlauf at gcc dot gnu.org wrote: > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113152 > > > > > > I think that you cannot do > > > > > > + if (MPFR_HALF_CYCLE) > > > > > > you really must use > > > > > > #if MPFR_HALF_CYCLE > > > > > > > #include <stdio.h> > > #include "mpfr.h" > > > > #define MPFR_HALF_CYCLE (MPFR_VERSION_MAJOR * 100 + MPFR_VERSION_MINOR >= > > 402) > > > > int > > main(void) > > { > > if (MPFR_HALF_CYCLE) > > printf("here\n"); > > else > > printf("there\n"); > > return (0); > > } > > > > % cc -o z -I/usr/local/include a.c && ./z > > This does not test the right thing. > > % cat sgk.cc > #include <stdio.h> > > #define MPFR_HALF_CYCLE 0 This is not what the pre-processor should be doing (on at least FreeBSD). See below. > int > main(void) > { > if (MPFR_HALF_CYCLE) > printf_not_declared_if_0 ("here\n"); > else > printf ("there\n"); > return (0); > } > > % g++ sgk.cc > sgk.cc: In function 'int main()': > sgk.cc:9:7: error: 'printf_not_declared_if_0' was not declared in this scope > printf_not_declared_if_0 ("here\n"); > ^~~~~~~~~~~~~~~~~~~~~~~~ Of course, it will fail. You need to actually have a printf_not_declared_if_0 function defined during parsing. #include <stdlib.h> #include <stdio.h> #define MPFR_HALF_CYCLE 1 #define printf_not_declared_if_0(a) abort() int main(void) { if (MPFR_HALF_CYCLE) printf_not_declared_if_0 ("here\n"); else printf ("there\n"); return (0); } ~/work/x/bin/g++ -I/usr/local/include -o z a.cc && ./z Abort (core dumped) Changing 1 to 0 the MPFR_HALF_CYCLE define. ~/work/x/bin/g++ -I/usr/local/include -o z a.cc && ./z there Going back to my original example and g++ from master, I'm seeing % ~/work/x/bin/g++ -I/usr/local/include -E a.cc int main(void) { if (( # 9 "a.cc" 3 4 # 9 "a.cc" * 100 + # 9 "a.cc" 3 2 # 9 "a.cc" >= 402)) printf("here\n"); else printf("there\n"); return (0); } and with clang++ % c++ -E -I/usr/local/include a.cc int main(void) { if ((4 * 100 + 2 >= 402)) printf("here\n"); else printf("there\n"); return (0); } Is there something that is different between your OS and FreeBSD? Or is there some fundamental difference between C and C++ that I am unaware of?