The following C code fails to compile with DMD 2.101.1: #include <math.h> float norm2D(float x, float y) { return sqrt(x*x + y*y); } DMD error message: #defines(1074): Error: variable `vec_math.FP_NAN` conflicts with enum member `__anonymous.FP_NAN` at /usr/include/math.h(936) #defines(1075): Error: variable `vec_math.FP_INFINITE` conflicts with enum member `__anonymous.FP_INFINITE` at /usr/include/math.h(939) #defines(1076): Error: variable `vec_math.FP_ZERO` conflicts with enum member `__anonymous.FP_ZERO` at /usr/include/math.h(942) #defines(1077): Error: variable `vec_math.FP_SUBNORMAL` conflicts with enum member `__anonymous.FP_SUBNORMAL` at /usr/include/math.h(945) #defines(1078): Error: variable `vec_math.FP_NORMAL` conflicts with enum member `__anonymous.FP_NORMAL` at /usr/include/math.h(948) The problem seems to be caused by this strange enum declaration in math.h: enum { FP_NAN = # define FP_NAN 0 FP_NAN, FP_INFINITE = # define FP_INFINITE 1 FP_INFINITE, FP_ZERO = # define FP_ZERO 2 FP_ZERO, FP_SUBNORMAL = # define FP_SUBNORMAL 3 FP_SUBNORMAL, FP_NORMAL = # define FP_NORMAL 4 FP_NORMAL };
What's happening is ImportC sees those macro definitions and transforms them into manifest constant declarations. Those declarations then conflict with the enum declarations.
A reduced test case: enum { FP_NAN = 0 }; #define FP_NAN 0
@WalterBright created dlang/dmd pull request #14811 "fix Issue 23622 - ImportC #defines conflict with declarations" fixing this issue: - fix Issue 23622 - ImportC #defines conflict with declarations https://github.com/dlang/dmd/pull/14811
dlang/dmd pull request #14811 "fix Issue 23622 - ImportC #defines conflict with declarations" was merged into master: - 6ad91b95ce902a86199b234117b58bc48d14710a by Walter Bright: fix Issue 23622 - ImportC #defines conflict with declarations https://github.com/dlang/dmd/pull/14811