1 
2 // (C) Copyright Tobias Schwinger
3 //
4 // Use modification and distribution are subject to the boost Software License,
5 // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
6 
7 //------------------------------------------------------------------------------
8 
9 #ifndef BOOST_FT_CONFIG_COMPILER_HPP_INCLUDED
10 #define BOOST_FT_CONFIG_COMPILER_HPP_INCLUDED
11 
12 #include <boost/config.hpp>
13 #include <boost/detail/workaround.hpp>
14 
15 #if defined(BOOST_MSVC)
16 
17 #   if BOOST_MSVC < 1310
18 #     error "unsupported compiler version"
19 #   endif
20 
21 #   ifdef BOOST_FT_AUTODETECT_CALLING_CONVENTIONS
22 
23       // enable clrcall calling covention (call to .NET managed code) when
24       // compiling with /clr
25 #     if BOOST_MSVC >= 1400 && defined(__cplusplus_cli)
26 #       ifndef BOOST_FT_CC_CLRCALL
27 #       define BOOST_FT_CC_CLRCALL callable_builtin
28 #       endif
29 #     endif
30 
31       // Intel x86 architecture specific calling conventions
32 #     ifdef _M_IX86
33 #       define BOOST_FT_COMMON_X86_CCs callable_builtin
34 #       if BOOST_MSVC < 1400
35           // version 7.1 is missing a keyword to specify the thiscall cc ...
36 #         ifndef BOOST_FT_CC_IMPLICIT_THISCALL
37 #         define BOOST_FT_CC_IMPLICIT_THISCALL non_variadic|member|callable_builtin
38 #         ifndef BOOST_FT_CONFIG_OK
39 #           pragma message("INFO| /Gd /Gr /Gz will compiler options will cause")
40 #           pragma message("INFO| a compile error.")
41 #           pragma message("INFO| Reconfigure Boost.FunctionTypes in this case.")
42 #           pragma message("INFO| This message can be suppressed by defining")
43 #           pragma message("INFO| BOOST_FT_CONFIG_OK.")
44 #         endif
45 #         endif
46 #       else
47           // ...introduced in version 8
48 #         ifndef BOOST_FT_CC_THISCALL
49 #         define BOOST_FT_CC_THISCALL non_variadic|member|callable_builtin
50 #         endif
51 #       endif
52 #     endif
53 #   endif
54 
55 #elif defined(__GNUC__) && !defined(BOOST_INTEL_LINUX)
56 
57 #   if __GNUC__ < 3
58 #     error "unsupported compiler version"
59 #   endif
60 
61 #   ifdef BOOST_FT_AUTODETECT_CALLING_CONVENTIONS
62 
63 #     if defined(__i386__)
64 #       // see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20439
65 #       // see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29328
66 #       if BOOST_WORKAROUND(__GNUC__,BOOST_TESTED_AT(4))
67 #         ifndef BOOST_FT_CC_IMPLICIT
68 #         define BOOST_FT_CC_IMPLICIT member|callable_builtin
69 #         endif
70 #         define BOOST_FT_COMMON_X86_CCs non_member|callable_builtin
71 #       else
72 #         define BOOST_FT_COMMON_X86_CCs callable_builtin
73 #       endif
74 #     else
75 #       ifndef BOOST_FT_CC_IMPLICIT
76 #       define BOOST_FT_CC_IMPLICIT callable_builtin
77 #       endif
78 #     endif
79 #   endif
80 
81 #   if (defined(BOOST_FT_CC_CDECL) || defined(BOOST_FT_COMMON_X86_CCs)) \
82         && !defined(__cdecl)
83 #     define __cdecl __attribute__((__cdecl__))
84 #   endif
85 #   if (defined(BOOST_FT_CC_STDCALL) || defined(BOOST_FT_COMMON_X86_CCs)) \
86         && !defined(__stdcall)
87 #     define __stdcall __attribute__((__stdcall__))
88 #   endif
89 #   if (defined(BOOST_FT_CC_FASTCALL) || defined(BOOST_FT_COMMON_X86_CCs)) \
90         && !defined(__fastcall)
91 #     define __fastcall __attribute__((__fastcall__))
92 #   endif
93 
94 #elif defined(__BORLANDC__)
95 
96 #   if __BORLANDC__ < 0x550
97 #     error "unsupported compiler version"
98 #   elif __BORLANDC__ > 0x565
99 #     pragma message("WARNING: library untested with this compiler version")
100 #   endif
101 
102 #   ifdef BOOST_FT_AUTODETECT_CALLING_CONVENTIONS
103 #     define BOOST_FT_COMMON_X86_CCs callable_builtin
104 #   endif
105 
106     // syntactic specialities of cc specifier
107 #   define BOOST_FT_SYNTAX(result,lparen,cc_spec,type_mod,name,rparen) \
108                         result() cc_spec() lparen() type_mod() name() rparen()
109 #else
110     // only enable default calling convention
111 #   define BOOST_FT_CC_IMPLICIT callable_builtin
112 #endif
113 
114 
115 #endif
116 
117