JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Solaris Studio 12.3: C++ User's Guide     Oracle Solaris Studio 12.3 Information Library
search filter icon
search icon

Document Information


Part I C++ Compiler

1.  The C++ Compiler

2.  Using the C++ Compiler

3.  Using the C++ Compiler Options

Part II Writing C++ Programs

4.  Language Extensions

4.1 Linker Scoping

4.1.1 Compatibility with Microsoft Windows

4.2 Thread-Local Storage

4.3 Overriding With Less Restrictive Virtual Functions

4.4 Making Forward Declarations of enum Types and Variables

4.5 Using Incomplete enum Types

4.6 Using an enum Name as a Scope Qualifier

4.7 Using Anonymous struct Declarations

4.8 Passing the Address of an Anonymous Class Instance

4.9 Declaring a Static Namespace-Scope Function as a Class Friend

4.10 Using the Predefined __func__ Symbol for Function Name

4.11 Supported Attributes

4.11.1 __packed__ Attribute Details

4.12 Compiler Support for Intel MMX and Extended x86 Platform Intrinsics

5.  Program Organization

6.  Creating and Using Templates

7.  Compiling Templates

8.  Exception Handling

9.  Improving Program Performance

10.  Building Multithreaded Programs

Part III Libraries

11.  Using Libraries

12.  Using the C++ Standard Library

13.  Using the Classic iostream Library

14.  Building Libraries

Part IV Appendixes

A.  C++ Compiler Options

B.  Pragmas



4.11 Supported Attributes

The following are supported attributes:The following attributes, invoked by __attribute__ ((keyword)), or alternatively by [[keyword]], are implemented by the compiler for compatibility. Spelling the attribute keyword within double underscores, __keyword__, is also accepted.


Roughly equivalent to #pragma align. Generates a warning and is ignored if used on variable length arrays.


Equivalent to #pragma inline and -xinline


Equivalent to #pragma no_side_effect


Equivalent to #pragma init


Equivalent to #pragma fini


Equivalent to #pragma returns_new_memory


(No equivalent)


Equivalent to #pragma no_inline and -xinline


Equivalent to #pragma does_not_return


Equivalent to #pragma does_not_write_global_data


Equivalent to #pragma pack(). See details below.


Equivalent to #pragma unknown_control_flow


Accepted for compatibility with g++, but has no effect. The g++ documentation recommends not using this attribute.


Indicates that a variable or a type name (created using typedef) represents a vector.


Provides linker scoping. (See A.2.130 -xldscope={v}) Syntax is: __attribute__((visibility(“visibility-type”))), where visibility-type is one of:


Same as __global linker scoping


Same as __hidden linker scoping


Same as __symbolic linker scoping


Equivalent to #pragma weak

4.11.1 __packed__ Attribute Details

This attribute, attached to struct or union type definition, specifies that each member (other than zero-width bitfields) of the structure or union is placed to minimize the memory required. When attached to an enum definition, __packed__ indicates that the smallest integral type should be used.

Specifying this attribute for struct and union types is equivalent to specifying the packed attribute on each of the structure or union members.

In the following example, struct my_packed_struct's members are packed closely together but the internal layout of its s member is not packed. To do that, struct my_unpacked_struct would also need to be packed.

struct my_unpacked_struct
   char c;
   int i;
struct __attribute__ ((__packed__)) my_packed_struct
   char c;
   int  i;
   struct my_unpacked_struct s;

You may only specify this attribute on the definition of an enum, struct, or union, and not on a typedef that does not also define the enumerated type, structure, or union.