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: Anatoly V. Kalin <anatoly.v.kalin@…> 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)

clang.hpp.patch (311 bytes ) - added by Anatoly V. Kalin <anatoly.v.kalin@…> 10 years ago.
boost\config\compiler\clang.hpp.patch

Download all attachments as: .zip

Change History (3)

by Anatoly V. Kalin <anatoly.v.kalin@…>, 10 years ago

Attachment: clang.hpp.patch added

boost\config\compiler\clang.hpp.patch

comment:1 by John Maddock, 10 years ago

(In [83009]) Apply patch from 7452. Refs #7452.

comment:2 by John Maddock, 10 years ago

Resolution: fixed
Status: newclosed

(In [83139]) Merge changes from Trunk. Fixes #6013. Fixes #7151. Fixes #7359. Fixes #7389. Fixes #7452. Fixes #7528. Fixes #7703. Fixes #7841. Fixes #7898. Fixes #7938. Fixes #8048.

Note: See TracTickets for help on using tickets.