October 25, 2023
https://issues.dlang.org/show_bug.cgi?id=24200

          Issue ID: 24200
           Summary: ImportC: .di file collected macro conflicts with
                    Special Token
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: dave287091@gmail.com

My generated .di file includes the following:

        enum __VERSION__ = "Apple LLVM 15.0.0 (clang-1500.0.40.1)";

This leads to an error, as __VERSION__ is a special token in D. __VERSION__ is also pre-defined by the preprocessor.

If the macros include any of the special tokens (https://dlang.org/spec/lex.html#specialtokens), you will get errors.

For example, if your c file looks like:

#define __DATE__ 1
#define __TIME__  1
#define __TIMESTAMP__  1
#define __VENDOR__  1
#define __EOF__  1

Then, after converting to a .di file, you will get some enums that look like:

        enum int __DATE__ = 1;
        enum int __TIME__ = 1;
        enum int __TIMESTAMP__ = 1;
        enum int __VENDOR__ = 1;
        enum int __EOF__ = 1;

which will all error out

--