Menu

#1025 Collect C/C++ preprocessor definitions from Code::Blocks scripts

Undefined
open
nobody
Feature_Request
2020-12-29
2020-10-20
No

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.

1 Attachments

Discussion

  • Martin Turski

    Martin Turski - 2020-10-20

    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
  • Teodor Petrov

    Teodor Petrov - 2020-12-29

    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:
    1. The file is part of multiple targets - which one should we use to run the script? The currently selected one? What happens if the file is not part of it?
    2. What happens if the file is not in the current selected target?
    3. What happens if the file is part of multiple projects?

    Probably all of these should be answered anyway to make this feature work correctly for the non-scripted case.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.