#pragma OPTION: Additional Options

Scope

Compilation Unit or until next pragma OPTION

Syntax
  #pragma OPTION (ADD [<Handle>]{<Option>}|DEL ({Handle}|ALL)) 
  
Synonym

None

Arguments

<Handle>: This identifier allows selective deletion of added options.

<Option>: A valid option string enclosed in double quote (") characters

Default

None

Description

This pragma allows the addition of options inside the source code during file compilation.

Note: The options given on the command line or in a configuration file cannot be changed in any way.

Use the ADD command to add additional options to the current options. A handle may be given optionally.

Use the DEL command to remove all options with a specific handle or use the ALL keyword to remove all options.

Note: Only options added using #pragma OPTION ADD can be deleted using #pragma OPTION DEL.

All keywords and the handle are case-sensitive.

Restrictions:

Example

The following example illustrates compiling a single function with the additional -Or option.

Listing: Using the OPTION Pragma
#pragma OPTION ADD function_main_handle "-Or"
int sum(int max) { /* compiled with -or */

  int i, sum=0;

  for (i = 0; i < max; i++) {

    sum += i;

  }

  return sum;

}

#pragma OPTION DEL function_main_handle

/* now the same options as before the #pragma */

/* OPTION ADD are active again */

The following listing shows improper uses of the OPTION pragma.

Listing: Improper Uses of the OPTION Pragma
#pragma OPTION ADD -Or /* ERROR, use "-Or" */
#pragma OPTION  "-Or" /* ERROR, use keyword ADD */

#pragma OPTION ADD "-Odocf=\"-Or\"" 

/* ERROR, "-Odocf" not allowed in this pragma */

void f(void) {

#pragma OPTION ADD "-Or"

/* ERROR, pragma not allowed inside of declarations */

}

#pragma OPTION ADD "-Cni"

#ifdef __CNI__ 
/* ERROR, macros are not defined for options */

/* added with the pragma */

#endif