In the Code::Blocks "Configure editor" window under the "General settings" -> "C/C++ Editor settings" category you have the option "Include host platform defines".

Using this option you can successfully activate C++ #ifdef region activation for the linux platform define. Can you please add an option to collect defines from Code::Blocks squirrel scripts aswell? Take a look at the following example:
cbinit_script.sq
function SetBuildOptions(base)
{
base.AddCompilerOption(_T("-D COMPILED_UNDER_CODEBLOCKS"));
}
main.cpp
#include <stdio.h>
int main( int argc, char *argv[] )
{
#ifdef COMPILED_UNDER_CODEBLOCKS
printf( "hello Code::Blocks dev!\n" );
#else
printf( "hello C dev!\n" );
#endif
return 0;
}
Upon compilation the compiler should pick up the region enclosed under the #ifdef as active region instead of graying it out. Under Code::Blocks 20.03 it does not do so.
An example Code::Blocks project has been attached to this ticket.
Since it is impossible to edit my ticket on SourceForge, here is a fixed project .zip file as attachment. I forgot to save the project file in Code::Blocks before uploading it, sorry.
Last edit: Martin Turski 2020-10-20
This is very unlikely feature to see added, because I'm not sure we can design a set of rules to decide which script to execute, so we can generate the defines.
Example cases I can think of:
Probably all of these should be answered anyway to make this feature work correctly for the non-scripted case.