From: Marcus M. <ma...@je...> - 2008-12-19 08:04:30
|
> #ifdef __cplusplus > extern "C" { > #endif /* __cplusplus */ > > If __cpluplus is defined, then extern "C" is declared, { is opened, and then > there is an #endif. What do these three statements accomplish? > > > Near the bottom of the file, another #ifdef __cplusplus statement appears, > then the } is closed, and another #endif /* __cplusplus */ statement > appears. > > I do not understand the function of the second #ifdef __cplusplus statement > just before the }. > > What is the purpose of the declaration (made somewhere else in the library) > of __cplusplus? Where (in what file) is that declaration made? > > All of the other statements in the file exif-data.h are contained between { > and } , therefore, apparently controlled by the #ifdef __cplusplus > statement at the beginning. Why? libexif imports functions as "C" functions. For using libexif in a C++ program you of course need the prototypes, but the prototypes need to be marked as "C" functions, otherwise they are imported using C++ mangling of function names. The extern "C" { ... }; wrapper around the prototypes accomplishes exact that. The prototypes are visible to C++ code, but as C imports. Ciao, Marcus |