Compiler struggles with macro abuse
See original GitHub issueProject: ParadiseSS13/Paradise @ fdc7d2ce71e527cc0b21a530376aa399975fdefb
Stacktrace:
$ ./DMCompiler.exe "C:\Users\AffectedArc07\Documents\Paradise\paradise.dme"
Compiling paradise.dme
Unhandled exception. System.Exception: Invalid token DM_Preproc_TokenConcat(code\modules\maze_generation\maze_generator.dm:67:19, ##x)
at OpenDreamShared.Compiler.DMPreprocessor.DMPreprocessor.IncludeFile(String includePath, String file) in C:\Users\AffectedArc07\Documents\GitHub\Misc_Shit\OpenDream\OpenDreamShared\Compiler\DMPreprocessor\DMPreprocessor.cs:line 253
at OpenDreamShared.Compiler.DMPreprocessor.DMPreprocessor.IncludeFile(String includePath, String file) in C:\Users\AffectedArc07\Documents\GitHub\Misc_Shit\OpenDream\OpenDreamShared\Compiler\DMPreprocessor\DMPreprocessor.cs:line 65
at DMCompiler.Program.Preprocess(List`1 files) in C:\Users\AffectedArc07\Documents\GitHub\Misc_Shit\OpenDream\DMCompiler\Program.cs:line 106
at DMCompiler.Program.Main(String[] args) in C:\Users\AffectedArc07\Documents\GitHub\Misc_Shit\OpenDream\DMCompiler\Program.cs:line 28
Offending code:
#define LOG_MAZE_PROGRESS(proc2run, opname) \
do { \
var/timer = start_watch(); \
proc2run ;\
log_debug("\[MAZE] Operation '[opname]' on maze at [##x],[##y],[##z] took [stop_watch(timer)]s"); \
} while (FALSE)
Note: This is a total abuse of macros but works in DM so here we are. Ike told me to.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Compiler struggles with macro abuse · Issue #382
Some testing with BYOND's compiler shows that any instance of ##nonexistant_parameter is just replaced with nonexistant_parameter . But only if it's a macro...
Read more >What is the worst real-world macros/pre-processor abuse ...
Real-world? MSVC has macros in minmax.h, called max and min , which cause a compiler error every time I intend to use the...
Read more >How I Learned to Stop Worrying and Love Macros
The first one to compile wins, and the winning branch is used for the rest of the build process.
Read more >Why aren't macros included in most modern programming ...
I think the main reason is that macros are lexical. This has several consequences: The compiler has no way of checking that a...
Read more >Worst abuse of the C preprocessor | by Bill Huang
in C, has two types of macros, one is objects- like macro, the other is function-like macro. when the code goes to compilation,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Some testing with BYOND’s compiler shows that any instance of
##nonexistant_parameteris just replaced withnonexistant_parameter. But only if it’s a macro that takes parameters.A parameter preceded by ## in the macro body is substituted directly, without any spacesThis isnt a parameter.