29.12.2014 Views

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

RealView Compilation Tools Compiler Reference Guide - ARM ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Language Extensions<br />

Example 3-2 Linkage specification<br />

extern const int z; /* in read-only segment, cannot */<br />

/* be dynamically initialized */<br />

extern "C++:read/write" const int y; /* in read/write segment */<br />

/* can be dynamically initialized */<br />

extern "C++:read/write"<br />

{<br />

const int i=5; /* placed in read-only segment, */<br />

/* not extern because implicitly static */<br />

extern const T x=6; /* placed in read/write segment */<br />

struct S<br />

{<br />

static const T T x; /* placed in read/write segment */<br />

};<br />

}<br />

Constant objects must not be redeclared with another linkage. The code in Example 3-3<br />

produces a compile error.<br />

Example 3-3 <strong>Compiler</strong> error<br />

extern "C++" const T x;<br />

extern "C++:read/write" const T x; /* error */<br />

Note<br />

Because C does not have the linkage specifications, you cannot use a const object<br />

declared in C++ as extern "C++:read/write" from C.<br />

See also<br />

• --apcs=qualifer...qualifier on page 2-4.<br />

3.5.5 Scalar type constants<br />

Constants of scalar type can be defined within classes. This is an old form. The modern<br />

form uses an initialized static data member.<br />

<strong>ARM</strong> DUI 0348A Copyright © 2007, 2010 <strong>ARM</strong> Limited. All rights reserved. 3-17<br />

Non-Confidential

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

Saved successfully!

Ooh no, something went wrong!