04.01.2015 Views

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

RealView Compilation Tools - ARM Information Center

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 Compiler 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 />

Errors<br />

A warning is issued if you define a member of constant integral type within a class.<br />

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

ID101213<br />

Non-Confidential,

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

Saved successfully!

Ooh no, something went wrong!