devkitPro/citro3d

public functions changed to inline static

Stitchuuuu opened this issue · 4 comments

Hello !

I'm working on cpp3ds so it will be compatible with the 1.3.0 and there is some strange changes in the lib.

A lot of functions changed and have "static inline" instead of being defined in .h (like C3D_TexInit)
Those functions are not used at all in citro3d, so I suppose they were created for external use.

I'm not a pro on the C language, but after I googled, if I understand well, inline static are used to enhance performance when the function is used a lot in the code. And so inline functions are not visible outside of the file itself.

So why can't we use those functions, if they are not used at all in the code ? Is there a way to call them ? Will they be removed ? Or was it an error ?

fincs commented

And so inline functions are not visible outside of the file itself.
(...)
So why can't we use those functions, if they are not used at all in the code ?

This makes no sense. static inline functions can be used like any other. The static prevents the compiler from making the function a global symbol if it decides not to inline it (preventing duplicate global symbols if the function is used in multiple translation units). The inline gives a hint to the compiler that the function is a good candidate for inlining.

Hum... so why can't I use them in a separate file ?
When I compile DrawAttack, I have undefined reference, but when I try to just "define" them, it says "function already exist".

I can use the function in cpp3ds, no error, but it shows me an error when I compile an app or a game using cpp3ds.

Maybe it is something related to C++ using an inline static function in C? Because I have no clue at all of how fixing the problem. The only solution is to rewrite the same functions at this time.

fincs commented

Why do you want to redefine a function that is already defined? citro3d has been tested and is known to work with C++.

Can you at least tell us which function specifically is causing a problem?