Is there a pragma (or some such) that performs like the C preprocessor command:
#define SOMEOPTION
I would like definition of some debugging flags to automatically define others. For example:
when defined(DEPENDENTFLAG):
{.define(NEEDEDFLAG).}
so that NEEDEDFLAG gets automatically defined even when the nim compille command is:
nim c -d:DEPENDENTFLAG somesource.nim
Thanks
const Thing = 0
when declared(Thing):
const otherThing = 0
when declared(otherThing):
echo "we are here"
this works
{. emit: """#define SOMEOPTION""" .}
Literal, For C target.
i just want to say, i love how many good options nim has for such a simple thing.
Nim -- a buffet for the programmers taste
One that hasn't been mentioned yet is simply:
const NeededFlag = defined(DependentFlag)
when NeededFlag:
discard # code goes here
Many thanks for all the suggestions.
Since NEEDEDFLAG can also be set by:
nim c -d:NEEDEDFLAG etc.etc.
I need to use defined(NEEDEDFLAG) instead of declared(NEEDEDFLAG).
However the following inside nim.cfg worked for me:
@if BGMAP:
define:BGDUMP
@end
which is the actual example in use.
Where (URL) are the @ commands for nim.cfg documented?? I could not find them in https://nim-lang.org/docs/nimc.html