218
init_priority (
priority
In Standard C++, objects defined at namespace scope are guaranteed to be initialized in an order
in strict accordance with that of their definitions in a given translation unit. No guarantee is made
for initializations across translation units. However, GNU C++ allows users to control the order
of initialization of objects defined at namespace scope with the
specifying a relative
and 65535 inclusive. Lower numbers indicate a higher priority.
In the following example,
tribute has reversed that order:
Some_Class
Some_Class
Note that the particular values of
java_interface
This type attribute informs C++ that the class is a Java interface. It may only be applied to classes
declared within an
dispatched using GCJ's interface table mechanism, instead of regular virtual table dispatch.
7.9. Java Exceptions
The Java language uses a slightly different exception handling model from C++. Normally, GNU
C++ will automatically detect when you are writing C++ code that uses Java exceptions, and handle
them appropriately. However, if C++ code only needs to execute destructors when Java exceptions are
thrown through it, GCC will guess incorrectly. Sample problematic code is:
struct S { ~S(); };
extern void bar();
void foo()
{
S s;
bar();
}
The usual effect of an incorrect guess is a link failure, complaining of a missing routine called
__gxx_personality_v0
You can inform the compiler that Java exceptions are to be used in a translation unit, irrespective
of what it might think, by writing
must appear before any functions that throw or catch exceptions, or run destructors when
#pragma
exceptions are thrown through them.
You cannot mix Java and C++ exceptions in the same translation unit. It is believed to be safe to throw
a C++ exception from one file through another file compiled for the Java exception model, or vice
versa, but there may be bugs in this area.
7.10. Deprecated Features
In the past, the GNU C++ compiler was extended to experiment with new features, at a time when the
C++ language was still evolving. Now that the C++ standard is complete, some of those features are
superseded by superior alternatives. Using the old features might cause a warning in some cases that
the feature will be dropped in the future. In other cases, the feature might be gone already.
While the list below is not exhaustive, it documents some of the options that are now deprecated:
)
, a constant integral expression currently bounded between 101
priority
would normally be created before
A
A
__attribute__ ((init_priority (2000)));
B
__attribute__ ((init_priority (543)));
priority
extern "Java"
// is written in Java, and may throw exceptions
.
#pragma GCC java_exceptions
Chapter 7. Extensions to the C++ Language
do not matter; only their relative ordering.
block. Calls to methods declared in this interface will be
attribute by
init_priority
, but the
B
init_priority
at the head of the file. This
at-
Need help?
Do you have a question about the ENTERPRISE LINUX 3 - USING GCC and is the answer not in the manual?
Questions and answers