I got an error trying last time, but is it possible to inline functions and subs for a DLL file?
Code:int _stdcall test()
{
//where do I stick the inline statement at?
}
Printable View
I got an error trying last time, but is it possible to inline functions and subs for a DLL file?
Code:int _stdcall test()
{
//where do I stick the inline statement at?
}
If you are exporting the function, then no, it doesn't make much sense to inline it since other applications need to have access to it.
If it's a helper function of some sort that is not exported, then sure, you can mark it as inline:
But in your example, there's no reason to declare a calling convention *and* inline -- if you inline the function, there is no function call to be made, and hence no calling convention to be used ;)Code:inline void foo()
{
}
Also keep in mind that the "inline" statement is merely a suggestion to the compiler -- if the compiler disagrees with you about inlining the function it won't do it, even if you mark it as inline. To work around this you can use __forceinline (visual C++) or __attribute__((always_inline)) (gcc) instead, although even then the compiler might determine that the function isn't suitable to be inlined.
Ok, so if there's no point of inlining when using _stdcall, is there anything else i can use or am I stuck with the way it is?
inlining is something that happens during compilation. A DLL isn't involved until the linking stage. So no, you can never import the functions exported from a DLL as inline.
However, the DLL usually has a header file accompanying it. Small functions that the users of the DLL might find useful might be defined as inline in there.
However, if there are no such functions, and you don't have the DLL source code, there's nothing you can do.
Ok thanks. I guess it's not possible then.