Reformat conditionally non-compiled Code

Hello,

is there a way to force "Reformat Code" command to format also conditionally non-compiled code?

best regards Andreas

3 comments
Comment actions Permalink

This is what I mean:

#define FOO

#if defined(FOO)
     /* this will be reformated after "reformat code" - command*/
#elif defind(BAR)
     /* this not */
#endif

0
Comment actions Permalink

Hi Andreas.

Thanks for reporting, we know about the feature request already:

https://youtrack.jetbrains.com/issue/CPP-2286

You can upvote and add your comments.

But the request can’t be solved in near future, because its currently impossible parse all possibilities of conditional compilation directives.
0
Comment actions Permalink

Hi Anna,

is it possible to give compile-time defines to the clion gui?

I have different targets which share soure code. But they use different header files.

add_executable(prop1 main.c  f.c)
SET_TARGET_PROPERTIES(prop1 PROPERTIES COMPILE_DEFINITIONS "F1")

add_executable(prop2 main.c  f.c)
SET_TARGET_PROPERTIES(prop2 PROPERTIES COMPILE_DEFINITIONS "F2")


It always looks in main.c like F2 is defined, also if I select prop1 in "Select Run/Debug Configuration". But in f.c it always looks the other way around.

main.c:
#if defined(F1)
    #include "f1.h"    // this is gray
#elif defined(F2)
    #include "f2.h"    // this is strong
#endif


Build works in both command line and CLion
sample in attachment

best regards Andreas


Attachment(s):
prop.zip
0

Please sign in to leave a comment.