Using Barcode maker for iPhone Control to generate, create ANSI/AIM Code 39 image in iPhone applications.

OnBarcode.com/Code 39

GCC compilers predefine two identifiers that store the name of the current function. The __FUNCTION__ identifier stores the function name as it appears in the source code; while __PRETTY_FUNCTION__ stores the name pretty printed in a language-specific fashion. In C programs, the two function names are the same, but in C++ programs they are usually different. To illustrate, consider the following code from a program named FUNCTION_example.cc: #include <iostream> using namespace std; class c { public: void method_a(void) { cout << "Function " << __FUNCTION__ << " in " << __FILE__ << endl; cout << "Pretty Function " << __PRETTY_FUNCTION__ << " in " << __FILE__ << endl; } };

Using Barcode creation for iPhone Control to generate, create DataMatrix image in iPhone applications.

OnBarcode.com/DataMatrix

int main(void) { c C; C.method_a(); return 0; } At runtime, the output is: $ ./a.out Function method_a in FUNCTION_example.cc Pretty Function void c::method_a() in FUNCTION_example.cc In C++, __FUNCTION__ and __PRETTY_FUNCTION__ are variables. On the other hand, because they are not macros, #ifdef __FUNCTION__ is meaningless inside a function because the preprocessor does not do anything special with the identifier __FUNCTION__ (or __PRETTY_FUNCTION__). For a discussion of the same concept in GCC s C compiler, see the section Function Name As Strings in 1.

Note If you are updating existing code to work with GCC 3.2 and later, these newer GCC versions handle __FUNCTION__ and __PRETTY_FUNCTION__ the same way as __func__, which is defined by the C99 standard as a variable. Versions of GCC s C compiler prior to version 3.2 defined __FUNCTION__ and __PRETTY_FUNCTION__ as string literals, meaning that they could be concatenated with other string literals in character string definitions.

Using Barcode reader for Software Control to read, scan read, scan image in Software applications.

OnBarcode.com/Barcode

The Java and C++ exception handling models differ, and though g++ tries to guess when your C++ code uses Java exceptions, it is always safest to explicitly identify such situations to avoid link failures. To tell g++ that a block of code may use Java exceptions, insert the following pragma in the current translation unit before any code that catches or throws exceptions: #pragma GCC java_exceptions You cannot mix Java and C++ exceptions in the same translation unit.

CHAPTER 2 USING GCC S C++ COMPILER

Visibility Attributes and Pragmas for GCC C++ Libraries

A traditional problem when writing C++ libraries is that the number of visible ELF symbols can become huge, even when symbols are not used externally and therefore need not be made public. GCC versions 4.02 and later provide the new fvisibility=value option and related internal attributes to enable you to control this behavior in a fashion similar to the mechanism provided by __declspec(dllexport) in Microsoft s C++ compilers. The new fhidden option takes two possible values: default, to continue to export all symbols from the current object file (which is the default value if this option is not specified), and hidden, which causes g++ not to export the symbols from the current object module. These two visibility cases are reflected by two new per-function/class attributes for use in C++ applications: __attribute__ ((visibility("default"))) and __attribute__ ((visibility("hidden"))). By default, ELF symbols are still exported. To prevent ELF symbols from being exported from a specific object file, use the fvisibility=hidden option when compiling that file. This can lead to increased complexity when creating a C++ library using a single Makefile because it requires that you either set manual compilation options for each object file contained in a shared library, or that you add this option to your global compilation flags for the library and therefore do not export any symbols from any of a shared library s component object files. This can be a pain and is actually the wrong thing if you need to make certain symbols visible externally for debugging purposes or for catching exceptions for throwable entities within a library.