views:

271

answers:

1

I have following code:

static __inline__ LIST list_List(POINTER P)
{
  return list_Cons(P,list_Nil());
 }

After compilation I got following warning:

inlining is unlikely but function size may grow

I removed the inline and changed into the following :

static  LIST list_List(POINTER P)
{
  return list_Cons(P,list_Nil());
 }

Now I get the following warning:

list_List is defined but not used.

I didn't used to get above warning "function is defined but not used" before removing the inline. I got the warning only after I remove the inline. Actually the function is used .When i comment the above function, i am getting following error:

 list.o: In function `list_NReverse':
 list.c:(.text+0x148b): undefined reference to `list_List'
 list.o: In function `list_CopyWithElement':
 list.c:(.text+0x14ef): undefined reference to `list_List'
 list.c:(.text+0x150f): undefined reference to `list_List'
 list.o: In function `list_Copy':
 list.c:(.text+0x1549): undefined reference to `list_List'
 list.c:(.text+0x1569): undefined reference to `list_List'
 term.o:term.c:(.text+0x29e9): more undefined references to `list_List' follow
 collect2: ld returned 1 exit status
 make: *** [SPASS] Error 1

Can anybody please suggest me how can remove that warning.

+2  A: 

"static" means that the function can only be used within the scope of the current compilation unit (source file, basically, unless you're doing weird things with #include).

Thus, the compiler is warning you that you have declared a function that cannot be used outside the current source file, but which is not (currently) used within that source file either.

David Gelhar
In addition, when you told the compiler to inline the static function the compiler assumed that not using the function was not a problem because it is quite common for header files to have static inline functions that aren't used in every .c that includes them, but for a non-inline static this would be a little odd.
nategoose
@nategoose, u mean the manipulation of makefile can help to remove those warnings?
thetna
@thetna: No. I meant using the `inline` keyword made the compiler assume that the functions not being used was not a big deal.
nategoose