Summary:
- {$define}/{$undef} works on a code block basis, not a unit basis
- You can override both globally using the -u and -d options from the compiler for any unit or code block except the main project file
- You can not use -u and -d to override defines in the main project file: those will take precedence - that might be a bug, btw, not sure, any thoughts? -.
- You likely need the -B option (full rebuild) as well to guarantee proper behavior.
Basically you can not prevent this behavior. You either use these options or not.
I usually don't use these options, but rely on what is specified in the sourcecode.(except for -dDEBUG and -dRELEASE).
It can have unwanted side effects.