home  

pp_unbalanced_if_action

Properties

  Category: Preprocessor options
      Type: numeric [0 .. 2]
   Default: 0

Description

Action to perform when unbalanced #if and #else blocks are found.
0: do nothing
1: print a warning message
2: terminate the program with an error (EX_SOFTWARE)

The action will be triggered in the following cases:
- if an #ifdef block ends on a different indent level than
  where it started from. Example:

   #ifdef TEST
     int i;
     {
       int j;
   #endif

- an #elif/#else block ends on a different indent level than
  the corresponding #ifdef block. Example:

   #ifdef TEST
       int i;
   #else
       }
     int j;
   #endif

Examples

raw CPP code pp_unbalanced_if_action=0 pp_unbalanced_if_action=1 pp_unbalanced_if_action=2
/*-- this is the default sample --*/ int main(int argc, char** argv){ int n = 0; if(arg>=1){ printf("Hello %s!\n", argv[1]); n=strlen(argv[1]); }else{ puts("Hello world!"); } return n; } /*-- this is the default sample --*/ int main(int argc, char** argv){ int n = 0; if(arg>=1){ printf("Hello %s!\n", argv[1]); n=strlen(argv[1]); }else{ puts("Hello world!"); } return n; } /*-- this is the default sample --*/ int main(int argc, char** argv){ int n = 0; if(arg>=1){ printf("Hello %s!\n", argv[1]); n=strlen(argv[1]); }else{ puts("Hello world!"); } return n; } /*-- this is the default sample --*/ int main(int argc, char** argv){ int n = 0; if(arg>=1){ printf("Hello %s!\n", argv[1]); n=strlen(argv[1]); }else{ puts("Hello world!"); } return n; }
 

Not the best code for this option? See how to improve the .uds file used to generate these examples.