Opened 10 years ago
Closed 10 years ago
#7452 closed Patches (fixed)
Compiling Boost.Asio Example Error [with Clang compiled by MinGW gcc]
Reported by: | Owned by: | John Maddock | |
---|---|---|---|
Milestone: | To Be Determined | Component: | config |
Version: | Boost Development Trunk | Severity: | Problem |
Keywords: | Clang MinGW GCC i64 __int64 | Cc: |
Description
[Clang compiler and Boost builded by MinGW GCC 4.7.0]
Running a command
c:\lib\boost_1_51_0\doc\html\boost_asio\example\chat>clang++ -std=gnu++11 chat_client.cpp -D_WIN32_WINNT=0x0501 -Ic:/lib/boost_1_51_0 -Lc:/lib/boost_1_51_0/stage/lib -lboost_system-mgw47-mt-1_51 -lboost_thread-mgw47-mt-1_51 -Lc:/MinGW/lib -lws2_32
gives a lot of errors like this one:
In file included from chat_client.cpp:16: In file included from c:/lib/boost_1_51_0\boost/thread/thread.hpp:15: In file included from c:/lib/boost_1_51_0\boost/thread/win32/thread_data.hpp:15: '''c:/lib/boost_1_51_0\boost/chrono/system_clocks.hpp:130:15: error: invalid suffix 'i64' on integer constant''' typedef BOOST_SYSTEM_CLOCK_DURATION duration; ^ c:/lib/boost_1_51_0\boost/chrono/system_clocks.hpp:77:111: note: expanded from macro 'BOOST_SYSTEM_CLOCK_DURATION' ...boost::chrono::duration<boost::int_least64_t, ratio<BOOST_RATIO_INTMAX_C(1), BOOST_RATIO_INTMAX_C(10000000)> > ^ c:/lib/boost_1_51_0\boost/ratio/ratio_fwd.hpp:37:42: note: expanded from macro 'BOOST_RATIO_INTMAX_C' #define BOOST_RATIO_INTMAX_C(a) INTMAX_C(a) ^ c:/lib/boost_1_51_0\boost/cstdint.hpp:422:29: note: expanded from macro 'INTMAX_C' # define INTMAX_C(value) value##i64 ^ <scratch space>:52:2: note: expanded from macro '1' 1i64 ^
because in boost/config/compiler/clang.hpp:23
#if defined(__int64) # define BOOST_HAS_MS_INT64 #endif
and in boost/cstdint.h:391
# if defined(BOOST_HAS_MS_INT64) // // Borland/Intel/Microsoft compilers have width specific suffixes: // #ifndef INT8_C # define INT8_C(value) value##i8 #endif #ifndef INT16_C # define INT16_C(value) value##i16 #endif #ifndef INT32_C # define INT32_C(value) value##i32 #endif #ifndef INT64_C # define INT64_C(value) value##i64 #endif # ifdef __BORLANDC__ // Borland bug: appending ui8 makes the type a signed char # define UINT8_C(value) static_cast<unsigned char>(value##u) # else # define UINT8_C(value) value##ui8 # endif #ifndef UINT16_C # define UINT16_C(value) value##ui16 #endif #ifndef UINT32_C # define UINT32_C(value) value##ui32 #endif #ifndef UINT64_C # define UINT64_C(value) value##ui64 #endif #ifndef INTMAX_C # define INTMAX_C(value) value##i64 # define UINTMAX_C(value) value##ui64 #endif
These suffixes are not supported by "GCC version of Clang"(without -fms-extensions) and __int64 - MSVC feature. By the way, "-std=gnu++11 -fms-extensions" looks strange and "crutchly".
"-std=gnu++11" - a necessary workaround for Boost.Asio + MinGW
In general, replacing line boost\config\compiler\clang.hpp:23 by
#if defined(__int64) && !defined(__GNUC__)
solve the problem.
Same cure for the Trunk.
PS: Sorry for my English.
Attachments (1)
Note:
See TracTickets
for help on using tickets.
boost\config\compiler\clang.hpp.patch