In this compiler how can I force a function to be inline?
Printable View
In this compiler how can I force a function to be inline?
Is that really the standard way? Only class methods can be inline, and I believe the only way to really force inlining is compiler dependent. The keyword inline is something that the compiler may ignore ( but it tries not to ).
Unless you use a macro or something. But don't do that.
But we can declare non-class member function inline too! Yes it is true i is compiler dependent but can't we force inline in mingw as we use __forceinline in VC++?
Mingw does not define __forceinline. In general that's a bad idea to force inline functions, anyway, so you're probably better off finding another way to deal with your performance problem. Try using inline first; see if that does anything to help. And prove it's just as slow before you come back.
The problem witth function inlining is yes it can speed up the excution time, but this does come at the expense of a larger program size. The thing that can be hard to balance is program performance and program speed. Inlining a function is usually only done after you have the program working. If, you can see any bottlenecks in the code, then perhaps inlining a function to get a more effective result could be implemented. ( that is down to the compiler as citizen stated )