13.07.2015 Views

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>ARM</strong> <strong>User</strong> <strong>Guide</strong>Control program option: --define (-D)Menu entry1. Select C/C++ Compiler » Preprocessing and/or Assembler » Preprocessing.The Defined symbols box right-below shows the symbols that are currently defined.2. To define a new symbol, click on the Add button in the Defined symbols box.3. Type the symbol definition (<strong>for</strong> example, demo=1)Use the Edit and Delete button to change a macro definition or to remove a macro from the list.Command line syntax--define=macro_name[=macro_definition]-Dmacro_name[=macro_definition]DescriptionWith this option you can define a macro and specify it to the preprocessor. If you only specify a macroname (no macro definition), the macro expands as '1'.You can specify as many macros as you like. Simply use the Add button to add new macro definitions.On the command line, use the option --define (-D) multiple times. If the command line exceeds the limitof the operating system, you can define the macros in an option file which you then must specify to thecompiler with the option --option-file (-f) file.Defining macros with this option (instead of in the C source) is, <strong>for</strong> example, useful to compile conditionalC source as shown in the example below.The control program passes the option --define (-D) to the compiler and the assembler.ExampleConsider the following C program with conditional code to compile a demo program and a real program:void main( void ){#if DEMOdemo_func(); /* compile <strong>for</strong> the demo program */#elsereal_func(); /* compile <strong>for</strong> the real program */#endif}You can now use a macro definition to set the DEMO flag:596

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!