Linux, C++ and the extern "C" keyword

Robert Ambrose rna@testpt.com
Wed, 17 May 2000 10:16:16 -0700 (MST)


As usual, it depends.  If you're including the gnu library headers, they
are C++ aware.  If you're using somebody else's headers, it depends on if
they have made them C++ aware, i.e. YMMV.

The gnu headers defines two macros __BEGIN_DECLS which gets defined as
'extern "C" {' and __END_DECLS which is defined as '}' when the source is
C++.  The macros are defined as empty if the source is C.  If you look at
something like /usr/include/string.h, you will see a __BEGIN_DECLS hear
the beginning and a __END_DECLS at the end.  

rna

On Sun, 14 May 2000, Lucas Vogel wrote:

> I am reading a book on C++ and I have a question on how some of it might
> apply in the case of Linux. I believe the author of the book('Practical C++'
> by Rob McGregor) bases all of his work and examples on the Windows platform,
> though it isn't a windows-specific book. 
> 
> I also have another book that serves as an introduction to Linux
> programming, with all of the examples being done in C. The book describes of
> the many C-specific function calls that are available for the Linux
> platform.
> 
> My question is, if I wanted to write an application on Linux using these
> C-specific function calls, would I have to do anything with "extern 'C'" for
> the function calls, or would I be able to just #include the appropriate
> header files and rock out from there?
> 
> Thanks
> Lucas Vogel
> 
> _______________________________________________
> Plug-discuss mailing list  -  Plug-discuss@lists.PLUG.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>