11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

<strong>Compiler</strong> extensions●●●●Placement at an absolute address or in a named segmentThe @ operator or the directive #pragma location can be used for placing globaland static variables at absolute addresses, or placing a variable or function in a namedsegment. For more information about using these primitives, see Controlling dataand function placement in memory, page 116, and location, page 207.AlignmentEach data type has its own alignment, for more details, see Alignment, page 169. Ifyou want to change the alignment, the #pragma pack and #pragmadata_alignment directives are available. If you want to check the alignment of anobject, use the __ALIGNOF__() operator.The __ALIGNOF__ operator is used for accessing the alignment of an object. It takesone of two forms:● __ALIGNOF__ (type)●__ALIGNOF__ (expression)In the second form, the expression is not evaluated.Anonymous structs and unions<strong>C++</strong> includes a feature named anonymous unions. The compiler allows a similarfeature for both structs and unions in the C programming language. For moreinformation, see Anonymous structs and unions, page 115.Bitfields and non-standard typesIn ISO/ANSI C, a bitfield must be of type int or unsigned int. Using <strong>IAR</strong>Systems language extensions, any integer type or enumeration may be used. Theadvantage is that the struct will sometimes be smaller. This matches G.5.8 in theappendix of the ISO standard, ISO Portability Issues. For more information, seeBitfields, page 171.● Dedicated segment operators __segment_begin and __segment_endThe syntax for these operators is:void * __segment_begin(section)void * __segment_end(section)These operators return the address of the first byte of the named segment and thefirst byte after the named segment, respectively. This can be useful if you have usedthe @ operator or the #pragma location directive to place a data object or a functionin a user-defined segment.The named segment must be a string literal that has been declared earlier with the#pragma segment directive. If the segment was declared with a memory attributememattr, the type of the __segment_begin operator is a pointer to memattr void.Otherwise, the type is a default pointer to void. Note that you must have enabledlanguage extensions to use these operators.Part 2. <strong>Compiler</strong> <strong>reference</strong>181

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

Saved successfully!

Ooh no, something went wrong!