About Store Forum Documentation Contact



Post Reply 
Inline member functions
Author Message
zielony71 Offline
Member

Post: #1
Inline member functions
Hello everybody!

I am a begginer with Esenthel Engine. I've tried to compile my c++ code in the engine, with success but after many modifications. But I cannot resolve one problem: every method I have defined inside the class becomes non-inline functions after code-reorganization made by engine. Even methods explictly marked as inline. They all go to generated *.cpp file so they are not inline. The @namespace.class_name.h generated file (that can be found in External Dependencies folder in Visual Studio project) contains only declarations of member functions even if one is marked as inline.
So, how can I make an inline method ? It's very important, becasue non-inline small methods called frequently causes big overhead - it strongly decreases a performance.
I suspect, that the same problem I can have with free (non-member) functions.

Thanks in advance.
01-13-2016 09:37 AM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #2
RE: Inline member functions
inline mostly serves as an additional hint to the compiler in which case it will try 'harder' and solve if it has any benefits of being inlined or not, a compiler might optimize a function to be inline or not even without you writing the inline hint.

the way you generally say non-inline small methods is in many cases wrong, as the length isn't nessecarily the problem with inlining it is the complexity of the function.

There is also a huge misconception of all non complex functions should be inlined or not, you have to factor in if this function infact will be called alot or not, if you force inline on a function which is almost never called calling this function can in many cases infact be slower than having it non inlined.

You can however also export an empty code project to visual studio and program directly as well avoiding this case if this is in fact a problem for your project(this is by the way how I do it).

having a way to force EE's code reorganization to keep it inside the class/struct declaration or not would however be a welcome addition.
(This post was last modified: 01-13-2016 10:19 AM by Zervox.)
01-13-2016 10:18 AM
Find all posts by this user Quote this message in a reply
zielony71 Offline
Member

Post: #3
RE: Inline member functions
Zervox: It is true all that you have written, but:
If the whole function/method with its body is not contained in a header file, a compiler has no possibility to make it inline i.e. to place the code of the function/method directly in place of the calling. This is because the compiler doesn't have the body of the function/method. It has only its declaration. (It is the case of course, when the definition of the function/method is not actually in currently compiled .cpp file). So if the compiler cannot do it, then maybe a linker should. But as I know the linker does not do such a things.
So: In the case when the code is reorganized in the way the EE engine does it, there is no possibility that any method you defiened becomes de facto compiled as inline.

If there is no other way, maybe someone knows it ?

So now I will try to code in vs as you proposed.
01-13-2016 11:10 AM
Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #4
RE: Inline member functions
I code directly in VS too to avoid some of the pitfalls I came across using the Esenthel Editor. Unfortunately you lose a lot of the big advantages that come with using it so it's a decision that has to be made carefully.
01-13-2016 12:25 PM
Find all posts by this user Quote this message in a reply
zielony71 Offline
Member

Post: #5
RE: Inline member functions
Thank you guys, I will try to use VS. I didn't know that there is such a possibility, because each time I rebuilt a project in EE editor, the engine overwrote some my files that I modified/created in VS. But now I suppose that I should not mix building from EE editor and from VS.
01-13-2016 04:41 PM
Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #6
RE: Inline member functions
if you want to prevent that from happening you can export the project then copy it somewhere else, but you will need to update the project settings paths for the engine .lib and include directory.
01-13-2016 04:48 PM
Find all posts by this user Quote this message in a reply
zielony71 Offline
Member

Post: #7
RE: Inline member functions
I forgot to write about one important thing: I write an application for Android. And as I see, Visual Studio doesn't support that target, only EE Editor does. So what can I do in this situation ? Is there a way to walkaround these c++ restrictions of EE Editor for Android target ?
01-13-2016 10:57 PM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #8
RE: Inline member functions
Hi,

I will do some tests today, if there will be a significant performance difference for inline functions, I might add support for this for the next release.
01-18-2016 04:43 AM
Find all posts by this user Quote this message in a reply
Esenthel Online
Administrator

Post: #9
RE: Inline member functions
I've just fixed this in the source code "Beta" branch, and this will be available in the next release.

All you'll have to do is add the "inline" keyword for the function.
02-22-2016 05:55 AM
Find all posts by this user Quote this message in a reply
Post Reply