Boost logo

Boost :

Subject: Re: [boost] BOOST_FORCE_INLINE
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-10-09 19:50:28


On 10/09/2011 11:31 PM, Eric Niebler wrote:
> On 10/9/2011 12:52 PM, Mathias Gaunard wrote:
>> On 10/09/2011 06:56 PM, Beman Dawes wrote:
>>> On Sun, Oct 9, 2011 at 12:34 PM, Mathias Gaunard
>>> <mathias.gaunard_at_[hidden]> wrote:
>>>> On 10/09/2011 04:57 PM, Vicente J. Botet Escriba wrote:
>>>>>
>>>>> Le 09/10/11 15:30, Mathias Gaunard a écrit :
>>>>>>
>>>>>> I would like a BOOST_FORCE_INLINE macro to be added to
>>>>>> boost/config/suffix.hpp
>>>>>>
>>>>> What do you want BOOST_FORCE_INLINE to be replaced for?
>>>>
>>>> As the name suggests, __forceinline or __attribute__((always_inline))
>>>
>>> What compilers provide support? Do they spell it the same way?
>>
>> MSVC has __forceinline, GCC has __attribute((always_inline)), which
>> other compilers probably have as well (at least XL C/C++ seems to
>> support the same syntax as GCC).
>
> Do all compilers that support the directive expect it in the same place?
>

They're slightly different: __forceinline works just like the normal
inline specifier, while __attribute__((always_inline)) can be placed in
various places like other GCC attributes, but only has an effect if the
function is also inline.

So basically it should be something along the lines of

#if defined __GNUC__
#define BOOST_FORCE_INLINE __attribute__((always_inline)) inline
#elif defined BOOST_MSVC
#define BOOST_FORCE_INLINE __forceinline
#else
#define BOOST_FORCE_INLINE inline
#endif


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk