[config] BOOST_FORCEINLINE for clang
Hi, I would like to add the definition of BOOST_FORCEINLINE for clang when __has_attribute(always_inline) // BOOST_FORCEINLINE ---------------------------------------------// #if !defined(BOOST_FORCEINLINE) # if defined(_MSC_VER) # define BOOST_FORCEINLINE __forceinline +# elif defined(__clang__) +# if __has_attribute(always_inline) +# define BOOST_FORCEINLINE inline __attribute__((always_inline)) +# endif # elif defined(__GNUC__) && __GNUC__ > 3 # define BOOST_FORCEINLINE inline __attribute__ ((always_inline)) # else Could I commit it? Best, Vicente
2013/5/12 Vicente J. Botet Escriba
Hi,
I would like to add the definition of BOOST_FORCEINLINE for clang when __has_attribute(always_inline)
Hi, Please consider, what if __has_attribute(always_inline) is false in clang. By just reading the below, I think BOOST_FORCEINLINE won't be defined at all in that case. Shouldn't it be defined to something like plain old 'inline'? HTH, Kris
// BOOST_FORCEINLINE ------------------------------**---------------// #if !defined(BOOST_FORCEINLINE) # if defined(_MSC_VER) # define BOOST_FORCEINLINE __forceinline +# elif defined(__clang__) +# if __has_attribute(always_inline) +# define BOOST_FORCEINLINE inline __attribute__((always_inline)) +# endif # elif defined(__GNUC__) && __GNUC__ > 3 # define BOOST_FORCEINLINE inline __attribute__ ((always_inline)) # else
Could I commit it?
Best, Vicente
On 12/05/13 11:26, Vicente J. Botet Escriba wrote:
Hi,
I would like to add the definition of BOOST_FORCEINLINE for clang when __has_attribute(always_inline)
// BOOST_FORCEINLINE ---------------------------------------------// #if !defined(BOOST_FORCEINLINE) # if defined(_MSC_VER) # define BOOST_FORCEINLINE __forceinline +# elif defined(__clang__) +# if __has_attribute(always_inline) +# define BOOST_FORCEINLINE inline __attribute__((always_inline)) +# endif # elif defined(__GNUC__) && __GNUC__ > 3 # define BOOST_FORCEINLINE inline __attribute__ ((always_inline)) # else
Could I commit it?
What purpose does it serve? if defined(__GNUC__) && __GNUC__ > 3 is already true with clang.
John, I replaced `always_inline` in boost/config/suffix.hpp with `__always_inline__` to avoid interference with a macro with the same name. Committed in r84245 ( https://svn.boost.org/trac/boost/changeset/84245 ): --- boost/config/suffix.hpp (revision 84244) +++ boost/config/suffix.hpp (working copy) @@ -641,7 +641,7 @@ # if defined(_MSC_VER) # define BOOST_FORCEINLINE __forceinline # elif defined(__GNUC__) && __GNUC__ > 3 -# define BOOST_FORCEINLINE inline __attribute__ ((always_inline)) +# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__)) # else # define BOOST_FORCEINLINE inline # endif Regards, Michel
----------------------------------------
Date: Sun, 12 May 2013 22:59:21 +0900 From: mimomorin@gmail.com
I replaced `always_inline` in boost/config/suffix.hpp with `__always_inline__` to avoid interference with a macro with the same name.
Committed in r84245 ( https://svn.boost.org/trac/boost/changeset/84245 ): --- boost/config/suffix.hpp (revision 84244) +++ boost/config/suffix.hpp (working copy) @@ -641,7 +641,7 @@ # if defined(_MSC_VER) # define BOOST_FORCEINLINE __forceinline # elif defined(__GNUC__) && __GNUC__ > 3 -# define BOOST_FORCEINLINE inline __attribute__ ((always_inline)) +# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__)) # else # define BOOST_FORCEINLINE inline # endif
You should include a comment in the GCC section that it also works for Clang, due to Clang's GCC emulation. That way, later maintainers won't be wondering if Clang support should be added. (And help debugging if Clang ever stops emulating GCC by default.) Daryle W.
On 13/05/13 07:12, Daryle Walker wrote:
----------------------------------------
Date: Sun, 12 May 2013 22:59:21 +0900 From: mimomorin@gmail.com
I replaced `always_inline` in boost/config/suffix.hpp with `__always_inline__` to avoid interference with a macro with the same name.
Committed in r84245 ( https://svn.boost.org/trac/boost/changeset/84245 ): --- boost/config/suffix.hpp (revision 84244) +++ boost/config/suffix.hpp (working copy) @@ -641,7 +641,7 @@ # if defined(_MSC_VER) # define BOOST_FORCEINLINE __forceinline # elif defined(__GNUC__) && __GNUC__ > 3 -# define BOOST_FORCEINLINE inline __attribute__ ((always_inline)) +# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__)) # else # define BOOST_FORCEINLINE inline # endif
You should include a comment in the GCC section that it also works for Clang, due to Clang's GCC emulation. That way, later maintainers won't be wondering if Clang support should be added. (And help debugging if Clang ever stops emulating GCC by default.)
Isn't it common knowledge that Clang is compatible with GCC and pretends to be GCC 4.2, and that therefore most GCC-specific code will just work with Clang out of the box?
On 5/13/2013 4:44 AM, Mathias Gaunard wrote:
On 13/05/13 07:12, Daryle Walker wrote:
----------------------------------------
Date: Sun, 12 May 2013 22:59:21 +0900 From: mimomorin@gmail.com
I replaced `always_inline` in boost/config/suffix.hpp with `__always_inline__` to avoid interference with a macro with the same name.
Committed in r84245 ( https://svn.boost.org/trac/boost/changeset/84245 ): --- boost/config/suffix.hpp (revision 84244) +++ boost/config/suffix.hpp (working copy) @@ -641,7 +641,7 @@ # if defined(_MSC_VER) # define BOOST_FORCEINLINE __forceinline # elif defined(__GNUC__) && __GNUC__ > 3 -# define BOOST_FORCEINLINE inline __attribute__ ((always_inline)) +# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__)) # else # define BOOST_FORCEINLINE inline # endif
You should include a comment in the GCC section that it also works for Clang, due to Clang's GCC emulation. That way, later maintainers won't be wondering if Clang support should be added. (And help debugging if Clang ever stops emulating GCC by default.)
Isn't it common knowledge that Clang is compatible with GCC and pretends to be GCC 4.2, and that therefore most GCC-specific code will just work with Clang out of the box?
Probably, still seems relatively painless to add the comment that may help someone understand more easily in the future.
John Maddock wrote:
Michael, Do you want to go ahead and commit the comment?
Added a comment in r84310 ( https://svn.boost.org/trac/boost/changeset/r84310 ): # elif defined(__GNUC__) && __GNUC__ > 3 + // Clang also defines __GNUC__ (as 4) # define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__)) Regards, Michel
Daryle Walker wrote:
Committed in r84245 ( https://svn.boost.org/trac/boost/changeset/84245 ): --- boost/config/suffix.hpp (revision 84244) +++ boost/config/suffix.hpp (working copy) @@ -641,7 +641,7 @@ # if defined(_MSC_VER) # define BOOST_FORCEINLINE __forceinline # elif defined(__GNUC__) && __GNUC__ > 3 -# define BOOST_FORCEINLINE inline __attribute__ ((always_inline)) +# define BOOST_FORCEINLINE inline __attribute__ ((__always_inline__)) # else # define BOOST_FORCEINLINE inline # endif
You should include a comment in the GCC section that it also works for Clang, due to Clang's GCC emulation. That way, later maintainers won't be wondering if Clang support should be added. (And help debugging if Clang ever stops emulating GCC by default.)
What about doing it in a more explicit way (though redundant)? i.e. change # elif defined(__GNUC__) && __GNUC__ > 3 to # elif (defined(__GNUC__) && __GNUC__ > 3) || defined(BOOST_CLANG) Regards, Michel
participants (7)
-
Daryle Walker
-
John Maddock
-
Krzysztof Czainski
-
Mathias Gaunard
-
Michael Marcin
-
Michel Morin
-
Vicente J. Botet Escriba