Embedded C++. NXP CodeWarrior Development Studio
Reklama
Reklama
Chapter 21 AIOP Code Generation
}
SECTIONS {
.abs.00010000 LOAD (0x00010000): {} > APPL_INT_VECT
<...>
}
21.7.5 Specifying Jump Table Location
By default the CodeWarrior compiler and linker allocate jump tables for switch
statements in RAM. When the application executes from ROM, it is sometimes better to have the switch table allocated in ROM to reduce RAM requirements.
To tell the compiler and linker to place jump tables in an object code section that will be placed in ROM, use this directive in your C or C++ source code:
#pragma read_only_switch_tables on
Alternately, to tell the compiler to generate a branch tree in executable code instead of a jump table in a data section, use this directive in C or C++:
#pragma switch_tables off
21.7.6 Specifying Constant Data Location
By default, the CodeWarrior compiler allocates all constant values of a size greater than 8 bytes in the
.rodata
section. There are two solutions for storing constants with sizes smaller than 8 bytes to be allocated in this section:
Solution 1: Define the variable in section
.rodata
using the __declspec(section) directive in C or C++ source code.
shows an example.
Listing 21-13. Using __declspec(section) to store small constants in .rodata
#define SMALL_ROM_CONST __declspec(section ".rodata")
SMALL_ROM_CONST const unsigned int MyInt2 = 0x4534
21.8 Embedded C++
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
Freescale Semiconductor, Inc.
391
Embedded C++
Embedded C++ (EC++) is a subset of the ISO/IEC 14882:2003 C++ language that is intended to compile into smaller, faster executable code suitable for embedded systems.
Embedded C++ source code is upwardly compatible with ISO/IEC C++ source code.
•
•
Differences Between ISO C++ and EC++
•
21.8.1 Activating EC++
The table below describes the settings used to control Embedded C++ conformance.
Table 21-13. Controlling Embedded C++ conformance
To control this option from here...
CodeWarrior IDE source code command line
use this setting
EC++ Compatibility Mode in the C/C++ Language Settings panel
#pragma ecplusplus
-dialect ec++
To test for EC++ compatibility mode at compile time, use the
__embedded_cplusplus predefined symbol.
21.8.2 Differences Between ISO C++ and EC++
The EC++ proposal does not support the following ISO/IEC 14882:2003 C++ features:
•
•
•
•
•
•
21.8.2.1 Templates
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
392 Freescale Semiconductor, Inc.
Chapter 21 AIOP Code Generation
ISO/IEC C++ specifies templates. The EC++ proposal does not include template support for class or functions.
21.8.2.2 Libraries
The EC++ proposal supports the
<string>
,
<complex>
,
<ios>
,
<streambuf>
,
<istream>
, and
<ostream>
classes, but only in a non-template form. The EC++ specifications do not support any other ISO/IEC C++ libraries, including the STL-type algorithm libraries.
21.8.2.3 File Operations
The EC++ proposal does not support any file operations except simple console input and output file types.
21.8.2.4 Localization
The EC++ proposal does not contain localization libraries because of the excessive memory requirements.
21.8.2.5 Exception Handling
The EC++ proposal does not support exception handling.
21.8.2.6 Unsupported Language Features
The EC++ proposal does not support the following language features:
• mutable specified
• RTTI
• namespace
• multiple inheritance
• virtual inheritance
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
Freescale Semiconductor, Inc.
393
Embedded C++
21.8.3 EC++ Specifications
Topics in this section describe how to design software that adhere to the EC++ proposal:
•
•
21.8.3.1 Language Related Issues
To make sure your source code complies with both ISO/IEC 14882:2003 C++ and EC++ standards, follow these guidelines:
• Do not use RTTI (Run Time Type Identification).
• Do not use exception handling, namespaces, or other unsupported features.
• Do not use multiple or virtual inheritance.
21.8.3.2 Library-Related Issues
Do not refer to routines, data structures, and classes in the Main Standard Library (MSL) for C++.
CodeWarrior Development Studio for Advanced Packet Processing Build Tools Reference Manual, Rev.
10.2, 01/2016
394 Freescale Semiconductor, Inc.
Stáhnout
Reklama