diff --git a/include/boost/config.hpp b/include/boost/config.hpp index 055a2785..f37585eb 100644 --- a/include/boost/config.hpp +++ b/include/boost/config.hpp @@ -36,7 +36,7 @@ #endif // if we don't have a std library config set, try and find one: -#if !defined(BOOST_STDLIB_CONFIG) && !defined(BOOST_NO_STDLIB_CONFIG) && !defined(BOOST_NO_CONFIG) +#if !defined(BOOST_STDLIB_CONFIG) && !defined(BOOST_NO_STDLIB_CONFIG) && !defined(BOOST_NO_CONFIG) && defined(__cplusplus) # include #endif // if we have a std library config, include it now: diff --git a/include/boost/config/compiler/borland.hpp b/include/boost/config/compiler/borland.hpp index 7801c7fb..21f1d9ec 100644 --- a/include/boost/config/compiler/borland.hpp +++ b/include/boost/config/compiler/borland.hpp @@ -56,6 +56,7 @@ # define BOOST_NO_CV_VOID_SPECIALIZATIONS # define BOOST_NO_DEDUCED_TYPENAME // workaround for missing WCHAR_MAX/WCHAR_MIN: +#ifdef __cplusplus #include #include #ifndef WCHAR_MAX @@ -65,9 +66,10 @@ # define WCHAR_MIN 0 #endif #endif +#endif // __cplusplus // Borland C++ Builder 6 and below: -#if (__BORLANDC__ <= 0x564) +#if (__BORLANDC__ <= 0x564) && defined(__cplusplus) # ifdef NDEBUG // fix broken so that Boost.test works: diff --git a/include/boost/config/compiler/codegear.hpp b/include/boost/config/compiler/codegear.hpp index 9584a4e7..628afc23 100644 --- a/include/boost/config/compiler/codegear.hpp +++ b/include/boost/config/compiler/codegear.hpp @@ -60,7 +60,7 @@ // (Niels Dekker, LKEB, April 2010) # define BOOST_NO_COMPLETE_VALUE_INITIALIZATION -# ifdef NDEBUG +# if defined(NDEBUG) && defined(__cplusplus) // fix broken so that Boost.test works: # include # undef strcmp diff --git a/include/boost/config/compiler/digitalmars.hpp b/include/boost/config/compiler/digitalmars.hpp index ebeef767..ca560e9d 100644 --- a/include/boost/config/compiler/digitalmars.hpp +++ b/include/boost/config/compiler/digitalmars.hpp @@ -44,7 +44,9 @@ // // Is this really the best way to detect whether the std lib is in namespace std? // +#ifdef __cplusplus #include +#endif #if !defined(__STL_IMPORT_VENDOR_CSTD) && !defined(_STLP_IMPORT_VENDOR_CSTD) # define BOOST_NO_STDC_NAMESPACE #endif diff --git a/include/boost/config/compiler/intel.hpp b/include/boost/config/compiler/intel.hpp index 5e1ce49a..faa080fc 100644 --- a/include/boost/config/compiler/intel.hpp +++ b/include/boost/config/compiler/intel.hpp @@ -121,6 +121,7 @@ // in type_traits code among other things, getting this correct // for the Intel compiler is actually remarkably fragile and tricky: // +#ifdef __cplusplus #if defined(BOOST_NO_INTRINSIC_WCHAR_T) #include template< typename T > struct assert_no_intrinsic_wchar_t; @@ -134,6 +135,7 @@ template<> struct assert_intrinsic_wchar_t {}; // if you see an error here then define BOOST_NO_INTRINSIC_WCHAR_T on the command line: template<> struct assert_intrinsic_wchar_t {}; #endif +#endif #if defined(_MSC_VER) && (_MSC_VER+0 >= 1000) # if _MSC_VER >= 1200 diff --git a/include/boost/config/platform/linux.hpp b/include/boost/config/platform/linux.hpp index 6fdea0d6..a02aff78 100644 --- a/include/boost/config/platform/linux.hpp +++ b/include/boost/config/platform/linux.hpp @@ -11,7 +11,11 @@ #define BOOST_PLATFORM "linux" // make sure we have __GLIBC_PREREQ if available at all +#ifdef __cplusplus #include +#else +#include +#endif // // added to glibc 2.1.1 diff --git a/include/boost/config/platform/symbian.hpp b/include/boost/config/platform/symbian.hpp index ad379431..f869eec3 100644 --- a/include/boost/config/platform/symbian.hpp +++ b/include/boost/config/platform/symbian.hpp @@ -14,7 +14,7 @@ #define BOOST_SYMBIAN 1 -#if defined(__S60_3X__) +#if defined(__S60_3X__) && defined(__cplusplus) // Open C / C++ plugin was introdused in this SDK, earlier versions don't have CRT / STL # define BOOST_S60_3rd_EDITION_FP2_OR_LATER_SDK // make sure we have __GLIBC_PREREQ if available at all diff --git a/include/boost/config/select_stdlib_config.hpp b/include/boost/config/select_stdlib_config.hpp index f0204823..96ede002 100644 --- a/include/boost/config/select_stdlib_config.hpp +++ b/include/boost/config/select_stdlib_config.hpp @@ -14,7 +14,11 @@ // First include to determine if some version of STLport is in use as the std lib // (do not rely on this header being included since users can short-circuit this header // if they know whose std lib they are using.) -#include +#ifdef __cplusplus +# include +#else +# include +#endif #if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) // STLPort library; this _must_ come first, otherwise since diff --git a/include/boost/config/stdlib/dinkumware.hpp b/include/boost/config/stdlib/dinkumware.hpp index 33b56088..4cf2cf05 100644 --- a/include/boost/config/stdlib/dinkumware.hpp +++ b/include/boost/config/stdlib/dinkumware.hpp @@ -86,10 +86,12 @@ # define BOOST_NO_STD_LOCALE #endif +#ifdef __cplusplus #include #if !_HAS_EXCEPTIONS # define BOOST_NO_STD_TYPEINFO #endif +#endif // C++0x headers implemented in 520 (as shipped by Microsoft) // diff --git a/include/boost/config/stdlib/libcpp.hpp b/include/boost/config/stdlib/libcpp.hpp index 07c70433..bc023474 100644 --- a/include/boost/config/stdlib/libcpp.hpp +++ b/include/boost/config/stdlib/libcpp.hpp @@ -8,7 +8,7 @@ // config for libc++ // Might need more in here later. -#if !defined(_LIBCPP_VERSION) +#if !defined(_LIBCPP_VERSION) && defined(__cplusplus) # include # if !defined(_LIBCPP_VERSION) # error "This is not libc++!" diff --git a/include/boost/config/stdlib/msl.hpp b/include/boost/config/stdlib/msl.hpp index adb3d478..902809d0 100644 --- a/include/boost/config/stdlib/msl.hpp +++ b/include/boost/config/stdlib/msl.hpp @@ -26,7 +26,9 @@ #endif // check C lib version for +#ifdef __cplusplus #include +#endif #if defined(__MSL__) && (__MSL__ >= 0x5000) # define BOOST_HAS_STDINT_H diff --git a/include/boost/config/stdlib/sgi.hpp b/include/boost/config/stdlib/sgi.hpp index c8d77d55..bcf93cf4 100644 --- a/include/boost/config/stdlib/sgi.hpp +++ b/include/boost/config/stdlib/sgi.hpp @@ -91,7 +91,7 @@ // // If this is GNU libstdc++2, then no and no std::wstring: // -#if (defined(__GNUC__) && (__GNUC__ < 3)) +#if (defined(__GNUC__) && (__GNUC__ < 3) && defined(__cplusplus)) # include # if defined(__BASTRING__) # define BOOST_NO_LIMITS diff --git a/include/boost/config/stdlib/stlport.hpp b/include/boost/config/stdlib/stlport.hpp index d3069992..9991b5e5 100644 --- a/include/boost/config/stdlib/stlport.hpp +++ b/include/boost/config/stdlib/stlport.hpp @@ -9,7 +9,7 @@ // STLPort standard library config: -#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) && defined(__cplusplus) # include # if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) # error "This is not STLPort!" @@ -203,7 +203,7 @@ namespace std{ using _STLP_VENDOR_CSTD::strcmp; using _STLP_VENDOR_CSTD::strcpy; // // gcc-2.95.3/STLPort does not like the using declarations we use to get ADL with std::min/max // -#if defined(__GNUC__) && (__GNUC__ < 3) +#if defined(__GNUC__) && (__GNUC__ < 3) && defined(__cplusplus) # include // for std::min and std::max # define BOOST_USING_STD_MIN() ((void)0) # define BOOST_USING_STD_MAX() ((void)0) diff --git a/include/boost/config/suffix.hpp b/include/boost/config/suffix.hpp index 3f7e5ad7..30622872 100644 --- a/include/boost/config/suffix.hpp +++ b/include/boost/config/suffix.hpp @@ -379,7 +379,7 @@ // works as expected with standard conforming compilers. The resulting // double inclusion of is harmless. -# ifdef BOOST_NO_STDC_NAMESPACE +# if defined(BOOST_NO_STDC_NAMESPACE) && defined(__cplusplus) # include namespace std { using ::ptrdiff_t; using ::size_t; } # endif @@ -398,7 +398,7 @@ // BOOST_NO_STD_MIN_MAX workaround -----------------------------------------// -# ifdef BOOST_NO_STD_MIN_MAX +# if defined(BOOST_NO_STD_MIN_MAX) && defined(__cplusplus) namespace std { template @@ -509,7 +509,7 @@ namespace std { // but it's use may generate either warnings (with -ansi), or errors // (with -pedantic -ansi) unless it's use is prefixed by __extension__ // -#if defined(BOOST_HAS_LONG_LONG) +#if defined(BOOST_HAS_LONG_LONG) && defined(__cplusplus) namespace boost{ # ifdef __GNUC__ __extension__ typedef long long long_long_type; @@ -563,7 +563,7 @@ namespace boost{ // -#if defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS +#if defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS) && defined(__cplusplus) # include "boost/type.hpp" # include "boost/non_type.hpp" @@ -601,7 +601,7 @@ namespace boost{ // When BOOST_NO_STD_TYPEINFO is defined, we can just import // the global definition into std namespace: -#ifdef BOOST_NO_STD_TYPEINFO +#if defined(BOOST_NO_STD_TYPEINFO) && defined(__cplusplus) #include namespace std{ using ::type_info; } #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8d2bdb21..df613523 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -24,7 +24,8 @@ if $(is_unix) } test-suite config - : + : + [ compile config_test_c.c ] [ run config_test.cpp : #args : #input-files diff --git a/test/config_test_c.c b/test/config_test_c.c new file mode 100644 index 00000000..9955dbe6 --- /dev/null +++ b/test/config_test_c.c @@ -0,0 +1,9 @@ + + +#include + + +int main() +{ + return 0; +}