« Return to Thread: C++ header files

Re: C++ header files

by dwchin :: Rate this Message:

Reply to Author | View in Thread

The __cplusplus macro is part of the ISO C++ standard, defined
precisely because the standards committee knew (presumably) that there
would be people who would want to use their old plain C stuff.

Similarly, ISO C has the macro __STDC__ defined.

See here:  http://docs.sun.com/app/docs/doc/819-5267/bkaep?a=view

So, it is more than just idiom. It's required of a standards-compliant compiler.

Cheers,
    Dave

On Tue, Jun 24, 2008 at 7:13 PM, Andrew Reilly
<andrew-atlas@...> wrote:

> On Tue, Jun 24, 2008 at 05:50:10PM -0500, skip@... wrote:
>>     Clint> #ifdef __cplusplus
>>     Clint> extern "C"
>>     Clint> {
>>     Clint> #endif
>>     Clint> ....
>
>> That is the standard idiom.  It will instruct the C++ compiler to not mangle
>> the names between the braces (C linkage).  C compilers will not see it.
>
> This is probably the wrong forum, but I've never understood why
> that was considered to be the appropriate strategy.  Why should
> C code have a bunch of spurious C++-related fluff added?  Surely
> the correct approach is for C++ code to wrap C includes in
> extern "C", as the syntax would seem to indicate?
>
> Every other language that has some way of linking to C code (and
> most do) has to do its own compatability shimming, with it's own
> foreign-function interface.
>
> My guess is that the process started when it was assumed that
> C++ was the future of C, and eventually everything would just be
> C++.  That is much less clearly the case, now, IMO.
>
> Cheers,
>
> --
> Andrew
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Math-atlas-devel mailing list
> Math-atlas-devel@...
> https://lists.sourceforge.net/lists/listinfo/math-atlas-devel
>



--
Email: david.w.h.chin AT gmail.com dwchin AT lroc.harvard.edu
http://gallatin.physics.lsa.umich.edu/~dwchin/Work
Public key: http://david.w.h.chin.googlepages.com/crypto.html
pub 1024D/553CB7B8 2007-08-07 [expires: 2008-08-06]
 Key fingerprint = 0AD6 6DDC 204D AA4A 8957 52D1 0D93 C52A 553C B7B8
uid David Chin <david.w.h.chin AT gmail.com>
uid David Chin <dwchin AT lroc.harvard.edu>
uid David Chin <dwchin.lroc AT gmail.com>

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Math-atlas-devel mailing list
Math-atlas-devel@...
https://lists.sourceforge.net/lists/listinfo/math-atlas-devel

 « Return to Thread: C++ header files