mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-16 07:48:44 +01:00
777b182edd
This allowed me to standardize the sourcetar and sf/* scripts: the base directory (containing ./git) is now empty, except for maintenance scripts, while the source files and build scripts of the annotations are stored in a subdirectory of their own.
28 lines
1.2 KiB
Text
28 lines
1.2 KiB
Text
Static tt(const) hi(static data: const) data members should be initialized
|
|
like any other static data member: in source files defining these data
|
|
members.
|
|
|
|
Usually, if these data members are of integral or built-in primitive data
|
|
types the compiler accepts in-class initializations of such data
|
|
members. However, there is no formal rule requiring the compiler to do
|
|
so. Compilations may or may not succeed depending on the optimizations used by
|
|
the compiler (e.g., using tt(-O2) may result in a successful compilation, but
|
|
ti(-O0)hi(O0)hi(noopt)
|
|
(no-optimalizations) may fail to compile, but then maybe only when shared
|
|
libraries are used...).
|
|
|
|
In-class initializations of integer constant values (e.g., of types tt(char,
|
|
int, long), etc, maybe tt(unsigned)) is nevertheless possible using (e.g.,
|
|
anonymous) enums. The following example illustrates how this can be done:
|
|
verb(
|
|
class X
|
|
{
|
|
public:
|
|
enum { s_x = 34 };
|
|
enum: size_t { s_maxWidth = 100 };
|
|
};
|
|
)
|
|
|
|
To avoid confusion caused by different compiler options static data
|
|
members should always explicitly be defined and initialized in a source file,
|
|
whether or not tt(const).
|