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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>ARM</strong> <strong>User</strong> <strong>Guide</strong>C++ compiler option: --define (-D)Menu entry1. Select C/C++ Compiler » Preprocessing.The Defined symbols box 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[(parm-list)][=macro_definition]-Dmacro_name(parm-list)][=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'.Function-style macros can be defined by appending a macro parameter list to macro_name.You can specify as many macros as you like. Simply use the Add button to add new macro definitions.On the command line, you can use the option --define (-D) multiple times. If the command line exceedsthe limit of the operating system, you can define the macros in an option file which you then must specifyto the C++ compiler with the option --option-file (-f) file.The definition can be tested by the preprocessor with #if, #ifdef and #ifndef, <strong>for</strong> conditionalcompilations.ExampleConsider the following 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:382

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

Saved successfully!

Ooh no, something went wrong!