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.

Using <strong>C++</strong>To take advantage of Extended Embedded <strong>C++</strong> features in your source code, you mustuse the --eec++ compiler option. See --eec++, page 151.To set the equivalent option in the <strong>IAR</strong> Embedded Workbench IDE, selectProject>Options>C/<strong>C++</strong> <strong>Compiler</strong>>Language.Feature descriptionsWhen writing <strong>C++</strong> source code for the <strong>IAR</strong> C/<strong>C++</strong> <strong>Compiler</strong>, there are some benefitsand some possible quirks that you need to be aware of when mixing <strong>C++</strong> features—suchas classes, and class members—with <strong>IAR</strong> language extensions, such as <strong>IAR</strong>-specificattributes.CLASSESA class type class and struct in <strong>C++</strong> can have static and non-static data members,and static and non-static function members. The non-static function members can befurther divided into virtual function members, non-virtual function members,constructors, and destructors. For the static data members, static function members, andnon-static non-virtual function members the same rules apply as for statically linkedsymbols outside of a class. In other words, they can have any applicable <strong>IAR</strong>-specifictype, memory, and object attribute.The non-static virtual function members can have any applicable <strong>IAR</strong>-specific type,memory, and object attribute as long as a pointer to the member function can beimplicitly converted to the default function pointer type. The constructors, destructors,and non-static data members cannot have any <strong>IAR</strong> attributes.For further information about attributes, see Type qualifiers, page 176.Exampleclass A {public:static __data16 __no_init int i @ 60; //Located in data16 at//address 60};The this pointerThe this pointer used for referring to a class object or calling a member function of aclass object will by default have the data memory attribute for the default data pointertype. This means that such a class object can only be defined to reside in memory fromwhich pointers can be implicitly converted to a default data pointer. This restriction mayPart 1. Using the compiler103

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

Saved successfully!

Ooh no, something went wrong!