[Boost-bugs] [Boost C++ Libraries] #7452: Compiling Boost.Asio Example Error [with Clang compiled by MinGW gcc]

Subject: [Boost-bugs] [Boost C++ Libraries] #7452: Compiling Boost.Asio Example Error [with Clang compiled by MinGW gcc]
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-10-01 17:21:34


#7452: Compiling Boost.Asio Example Error [with Clang compiled by MinGW gcc]
----------------------------------------------------------+-----------------
 Reporter: Anatoly V. Kalin <anatoly.v.kalin@…> | Owner: johnmaddock
     Type: Patches | Status: new
Milestone: To Be Determined | Component: config
  Version: Boost Development Trunk | Severity: Problem
 Keywords: Clang MinGW GCC i64 __int64 |
----------------------------------------------------------+-----------------
 [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

 {{{
 #!cpp
 #if defined(__int64)
 # define BOOST_HAS_MS_INT64
 #endif
 }}}

 and in boost/cstdint.h:391

 {{{
 #!cpp
 # 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

 {{{
 #!cpp
 #if defined(__int64) && !defined(__GNUC__)
 }}}

 solve the problem.

 Same cure for the Trunk.

 PS: Sorry for my English.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/7452>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC