avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] __builtin_constant_p for inline func args with -Os


From: Andy H
Subject: Re: [avr-gcc-list] __builtin_constant_p for inline func args with -Os
Date: Sun, 08 Nov 2009 15:43:50 -0500
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Os is not inlining the function - since it believe it will cause code size to grow.

You can find this out by using inline warning option
-Winline

However, you can FORCE a function to be inlined thus

static inline void  digitalWrite(uint8_t pin, uint8_t val) __attribute__((always_inline));
static inline void  digitalWrite(uint8_t pin, uint8_t val)

...which fixs your problem

Andy


Paul Stoffregen wrote:
I'm trying to create an inline function (instead of a preprocessor macro) which uses __builtin_constant_p to test if its args are compile time constants.  According to the manual, this is supposed to work with optimization enabled.

  You may use this built-in function in either a macro or an inline
  function. However, if you use it in an inlined function and pass an
  argument of the function as the argument to the built-in, GCC ....
  will not return 1 when you pass a constant numeric value to the
  inline function unless you specify the -O option.

Indeed it works great with -O2.  But with -Os, __builtin_constant_p never returns 1.

Is this a bug?  Or is __builtin_constant_p just not supported with -Os?  Or did I do something stupidly wrong?

My test code is attached.

Thanks,

-Paul





_______________________________________________ AVR-GCC-list mailing list address@hidden http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]