target attributes, pragmas and preprocessor macros

Christian Bruel
Mon May 18 06:26:00 GMT 2015

Hi Kyrill,

On 05/13/2015 05:43 PM, Kyrill Tkachov wrote:
> Hi all,
> Are target attributes supposed to redefine the preprocessor macros available?
> For example, on aarch64 if the file is compiled with floating point support
> the __ARM_FEATURE_FMA predefine is available. If the user adds to a function
> a target attribute disabling floating point, then is __ARM_FEATURE_FMA supposed
> to be undefined in the body of that function?
> Looking at some backends, it seems that only #pragmas are supposed to have that effect,
> but I just wanted to confirm.

yes they do, But careful, even the "inherited" macros should be redefined...

for instance for arm/thumb we can have something like:

#pragma GCC target ("thumb")

#ifndef __thumb__
#error "__thumb__ is not defined"

#ifdef __thumb2__
#ifndef __ARM_32BIT_STATE
#error  "__ARM_32BIT_STATE is not defined"
#else /* thumb1 */
#ifdef __ARM_32BIT_STATE
#error  "__ARM_32BIT_STATE is defined"
#endif /* thumb1 */


> Thanks,
> Kyrill



More information about the Gcc mailing list