You are not logged in.

#1 2009-04-17 01:04:34


[DONE] Proper inline function uses

Hello !

Every time I compile a project, I get many warnings concerning inlined functions, such as :


d:/Wii/Dev/Projects/IFace/source/../GRRLIB/GRRLIB/GRRLIB.h:86: warning: inline function 'void GRRLIB_DrawImg(f32, f32, GRRLIB_texImg, float, float, f32, u32)' used but never defined

It appears that the grrlib is not using inlined functions as they should be, and as a result these functions are NOT inlined by the compiler.
I found a really good guide on inlined functions, here :
Actually, what you're doing in your way is that :

A function defined with "inline" on its own. Stand-alone object code is always emitted. You can only write one definition like this in your entire program. If you want to use it from other translation units to the one where it is defined, you put a declaration in a header file; but it would not be inlined in those translation units.

You are effectively defining the function with "inline" in the source file (.c), and declarating it in a header file (.h) (you should not put "inline" in the header file, the compiler doesn't understand it and skip it). Thus, as a result, the function is not inlined in the other source files (translation units) that use it, like the files of our own projects, so here, "inline" is useless wink

According to the guide, what you need to do is to put the entire definition in the header file, and to append the "static" keyword to the definition.
The other solutions are to mess with the "extern" keyword.

I agree, all of this is not very convenient, but it is because inlined functions were introduced to be small and fast functions used statically by programs, not part of libraries. You should then choose one of the previous ways (the "static inline in the header" one is the best, or drop the use of the inline keyword wink

Thanks for reading big_smile

PS : I'm no real expert in C, so maybe I'm completely wrong, but I'm attached to standards and I see what I see : my compiler doesn't love these inlined functions. smile

Last edited by Obli (2009-04-17 01:06:20)



#2 2009-04-17 02:13:37

Bad Mother Fucker

Re: [DONE] Proper inline function uses

I think this as been fixed in the svn version: … LIB/GRRLIB



#3 2009-04-17 02:51:25


Re: [DONE] Proper inline function uses

Yes it has, thanks, I was not aware of a svn version !



Board footer

Powered by FluxBB