Closed MiranDMC closed 8 months ago
Use $INCLUDE_ONCE to add the same constants in any scope and avoid compiler error on duplicate name.
the only problem is that language service does not know about INCLUDE_ONCE and you won't get constants in auto-complete. I fixed it, try this core.zip
I noticed the problem with language service too.
Include_Once won't help in case of circular references, as one of two will be always included first. It leads to need of spiting code into header and source files. This makes code in example less readable as scm
Can you provide a complete project with includes so I can see it for myself?
Header with constant definitions offers walk-around.
I have some thoughts about constants. It is bit problematic that constants are valid only in code after they were declared. In bigger projects with includes it is getting very difficult as at certain point it is even impossible to manage correct include order to make sure constants can be used everywhere. I mean there are some cases where defined constants should be available globally in same way labels are:
In this example function
FUNC_SET_STUFF
will be available globally but depending on includes order callingcleo_call @FUNC_SET_STUFF args 1 Stuff_Blue
will cause argument of function to be actually default 0, as constantStuff_Blue
will be unknown.Modifying behaviour of existing constants might probably not be wise idea, so how about add extra keyword to declaration like
global const
?