추가적으로, 참고할 내용

http://david.tribble.com/text/cdiffs.htm#C90-aggreg-init c99 의 특징들에 대한 문서. 읽어볼것.

이 문서는

gcc 만의 특징들만을 적어두기 위한 페이지다. gcc 에서만 쓰는 pragma 라든지.. 등등. 원문들은 http://gcc.gnu.org 에서 찾아볼수 있다.

Declarations and Definitions in One Header

C++ object definitions can be quite complex. In principle, your source code will need two kinds of things for each object that you use across more than one source file. First, you need an interface specification, describing its structure with type declarations and function prototypes. Second, you need the implementation itself. It can be tedious to maintain a separate interface description in a header file, in parallel to the actual implementation. It is also dangerous, since separate interface and implementation definitions may not remain parallel.

With GNU C++, you can use a single header file for both purposes.

Warning: The mechanism to specify this is in transition. For the nonce, you must use one of two #pragma commands; in a future release of GNU C++, an alternative mechanism will make these #pragma commands unnecessary.

The header file contains the full definitions, but is marked with #pragma interface in the source code. This allows the compiler to use the header file only as an interface specification when ordinary source files incorporate it with #include. In the single source file where the full implementation belongs, you can use either a naming convention or #pragma implementation to indicate this alternate use of the header file.

#pragma interface 
#pragma interface "subdir/objects.h"

#pragma implementation 
#pragma implementation "objects.h" 

#pragma implementation and #pragma interface also have an effect on function inlining. 

Declaring Attributes of Functions

In GNU C, you declare certain things about functions called in your program which help the compiler optimize function calls and check your code more carefully.

constructor/destructor

deprecated

Specifying Attributes of Variables

역시 몇가지만 뽑아서 베낀다.

aligned (alignment)

packed

deprecated

results in a warning on line 3 but not line 2.

Specifying Attributes of Types

역시 쓸만한놈은 deprecated 밖에..

deprecated

Function Names as Strings

GCC predefines two magic identifiers to hold the name of the current function. The identifier FUNCTION holds the name of the function as it appears in the source. The identifier PRETTY_FUNCTION holds the name of the function pretty printed in a language specific fashion.

These names are always the same in a C function, but in a C++ function they may be different. For example, this program:

gives this output:

The compiler automagically replaces the identifiers with a string literal containing the appropriate name. Thus, they are neither preprocessor macros, like FILE and LINE, nor variables. This means that they catenate with other string literals, and that they can be used to initialize char arrays. For example

On the other hand, #ifdef FUNCTION does not have any special meaning inside a function, since the preprocessor does not do anything special with the identifier FUNCTION.

Note that these semantics are deprecated, and that GCC 3.2 will handle FUNCTION and PRETTY_FUNCTION the same way as func. func is defined by the ISO standard C99:

By this definition, func is a variable, not a string literal. In particular, func does not catenate with other string literals.

In C++, FUNCTION and PRETTY_FUNCTION are variables, declared in the same way as func.

Options That Control Optimization

아주 간략히

-O, -O1

-O turns on the following optimization flags:

-O2

-O3

-O0

-Os

Arrays of Length Zero


CategoryCpp

gcc기능들 (last edited 2005-02-11 08:34:22 by )