Bug 23401 – ImportC: add -cpp=filename switch to select C preprocessor

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-10-10T13:03:47Z
Last change time
2023-04-19T07:52:18Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
Adam D. Ruppe

Comments

Comment #0 by destructionator — 2022-10-10T13:03:47Z
When cross compiling, you often need to use a different preprocessor to get the right platform defines. the CC env var doesn't get used here and there's no switch to do it. Of course, dmd doesn't do much cross compile anyway but it would still be nice to have a way to do it.
Comment #1 by bugzilla — 2023-04-09T06:20:43Z
Actually, dmd cross compiles using the -os=windows, -os=freebsd, etc., switch. I use it all the time. But you're right, there's a problem with cross-compilation of .c files because how does one run the C preprocessor on another platform?
Comment #2 by bugzilla — 2023-04-16T06:41:13Z
Adam - can you suggest a proposal for how to specify which preprocessor is run?
Comment #3 by destructionator — 2023-04-16T12:42:25Z
I'd do a command line switch. `-importc-cpp=whatever` sets whatever as the command to use as the preprocessor. Then copy gdc's `-Xpreprocessor arg` to pass extra arguments to the preprocessor.
Comment #4 by bugzilla — 2023-04-18T04:57:09Z
You can currently set the environment variable CPPCMD to the C preprocessor to use.
Comment #5 by dlang-bot — 2023-04-18T05:09:23Z
@WalterBright created dlang/dmd pull request #15112 "fix Issue 23401 - ImportC: add -cpp=filename switch to select C prepr…" fixing this issue: - fix Issue 23401 - ImportC: add -cpp=filename switch to select C preprocessor https://github.com/dlang/dmd/pull/15112
Comment #6 by dlang-bot — 2023-04-19T07:52:18Z
dlang/dmd pull request #15112 "fix Issue 23401 - ImportC: add -cpp=filename switch to select C prepr…" was merged into master: - f79a7a4b68f5f7cbfef58249f4c9be7a98b699cd by Walter Bright: fix Issue 23401 - ImportC: add -cpp=filename switch to select C preprocessor https://github.com/dlang/dmd/pull/15112