Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

warning: always_inline function might not be inlinable [-Wattributes]

Tags:

c

when i try to include a .h file which consists of definition for inline functions as

__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SLA (int32_t o1, int32_t o2, int32_t o3)

it is giving the "warning: always_inline function might not be inlinable [-Wattributes]" can you somebody help me i am struggling to fix it.

like image 984
Ramarao Mundru Avatar asked Sep 07 '15 06:09

Ramarao Mundru


3 Answers

For functions declared inline(!!!!), this attribute inlines the function independent of any restrictions that otherwise apply to inlining.

So, when you set the attribute without declaring the function inline you will get these warning. Declare the function additionally inline will void these warnings. Behavior gnu gcc/g++ 5.30

# define FORCE_INLINE __attribute__((always_inline)) inline

FORCE_INLINE vec3 operator- (vec3 a, vec3 b) { vec3 t = { a.x-b.x, a.y-b.y, a.z-b.z }; return t; }
like image 106
sukumi Avatar answered Oct 19 '22 15:10

sukumi


finally, after spending two days efforts found the solution as it is below

it is just because of a compiler(arm-none-eabi-gcc) option in Makefile CFLAGS= -D inline if this flag is set, it throws warning as __attribute__( ( always_inline ) ) __STATIC_INLINE(inline) uint32_t __SLA (int32_t o1, int32_t o2, int32_t o3) when trying to include a .h file which consists of always inline functions

like image 33
Ramarao Mundru Avatar answered Oct 19 '22 15:10

Ramarao Mundru


What that warning is saying is that the compiler, is not always happy accepting your function as inline, or it wants it to be declared as inline.

I guess it's that __attribute__ ((always_inline)) implies inline - in which case the parsing of the attribute needs to set DECL_DECLARED_INLINE_P.

The GCC manual specifies

always_inline Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified.

Here's the gcc test for the revision

like image 1
Kiloreux Avatar answered Oct 19 '22 17:10

Kiloreux