How do you insert #define statements into a VM project? The places it would make sense to do so are all under the editor's control. I'd like to put logging code into #ifdef blocks so I don't have to always find and comment it out.
Reid
Preprocessor Defines
-
- Posts: 625
- Joined: Mon Nov 15, 2021 9:23 pm
Preprocessor Defines
Cyberwerks Heavy Industries -- viewforum.php?f=76
Re: Preprocessor Defines
I might well be misunderstanding your question but if all you want is to switch debugging code on and off...
Java doesn't have a preprocessor like C or C++ as there is no real need.
Java compilers do flow analysis therefore they simply do not generate code for statements that will never execute, so you can just use regular if statements instead of #if without there being any runtime overheads.
So you might want to have the following...
Then you can just write...
Java doesn't have a preprocessor like C or C++ as there is no real need.
Java compilers do flow analysis therefore they simply do not generate code for statements that will never execute, so you can just use regular if statements instead of #if without there being any runtime overheads.
So you might want to have the following...
Code: Select all
final boolean DEBUG = false;
Code: Select all
if( DEBUG )
{
doSomething();
}
-
- Posts: 625
- Joined: Mon Nov 15, 2021 9:23 pm
Re: Preprocessor Defines
Thanks, Colin. I got misled by my editor, which for some reason has macro entries for C-style preprocessor pragmas. Never mind.
Reid
Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76