How to avoid this warning?

How to avoid this warning?


I am writing a program in C, but when I compile it I get a warning that confuses me quite a bit and I would appreciate it if someone could enlighten me on this.One part ofthe programis a header file, where I have this prototype:

__inline__ void atomic_dec(volatile long *var);

In another file (.c extension)I declare the function atomic_decas:

__inline__ void atomic_dec(volatile long *var)
__asm__ __volatile__( "lock
"decl %0
: "m" (*var)
: "memory");
The header file is included in all source files.When the function atomic_dec is not used in a source file everything compiles correctly, but when it is used I get the following warning while compiling the source file:

warning #864: extern inline function "atomic_dec" was referenced but not defined
__inline__ void atomic_dec(volatile long *var);
I am confused from this warning. What does it mean?What am I doing wrong in the code and how can I avoid it?

The warning shows upwith both version 7.1.033 and 8.0.055 of the compiler.GCC does not give a warning for the same code.

I use the command line options:

-w1 -O3 -ip -ipo -ipo_obj -Ob2 -unroll -align -Zp16 -tpp6 -xK -i_dynamic -Bdynamic -D_REENTRANT

Thank you in advance for your help.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

I am not able reproduce your problem. I have created a .h and .c file;
referenced atomic_dec function from main function and compiled this with
Intel compiler. It compiled without any warning.
If possible, please attach your source files?



I guess your problem is that you put the function definition in a .c file. When you compile a different source file it does not "see" the definition and can not inline it. I think a normal function call will be done at the place of the warning (but maybe it will not be done because of the global optimization, but that is something the compile decides and not you).

I am not absolutely sure, but I suspect that this is happening: The high level optimizations work over multiple source files, but they are not "extending the language". That is they do not allow you things that are not possible without the optimization (like manually inlineing from one source file to another).

So I would suggest that you put the inline function definition in the header files.


Leave a Comment

Please sign in to add a comment. Not a member? Join today