Boost logo

Boost :

From: Herve Bronnimann (hervebronnimann_at_[hidden])
Date: 2006-10-16 14:59:02

[Apologies for duplicates, I don't know if an earlier posting went through because I wasn't subscribed under this email address]
Dear boosters: According to the C++ standard, language linkage is part of the specification of a type and even though on many platforms two function types with different linkage specs (eg. C and C++ language linkage) are the same, the standard states rather unambiguously ([7.5]) "Two function types with different language linkages are distinct types even if they are otherwise identical."

My question: does anyone know of a technique to determine the linkage of a function type at compile time? I'm not sure that that would matter for my purposes, but the question arose and I couldn't find an answer. Thanks for any feedback,
--Herve Bronnimann

PS: here's a concrete example of what I'm asking, a metafunction LinkageTraits that would make the following example compile (code obviously untested - all errors mine):

   #include <boost/static_assert.h>
   #include <boost/type_traits.h>

   struct CPPLinkageTag {};
   struct CLinkageTag {};

   extern "C" {
     typedef void functionWithCLinkageType();
   typedef void functionWithCPPLinkageType();

                      CLinkageTag >::value
                      CPPLinkageTag >::value

Boost list run by bdawes at, gregod at, cpdaniel at, john at