qt - Is there a way to prevent a header defined c++ function from being treated as inlined -


I am creating a QT application and as I was coding, I used to define my slot in the header . I came to know that it was easy to develop for me in this way, although I still define normal functions in .cpp (unless the function is actually small). But now there are some myths with my colleague that it is bad behavior to put in the header because they make the fact of defining the headers inline them, so I am trying to understand everything about what is going on. The reason for this is that I was given:

"Even in linear work (as per the requirement according to classrooms) is a highly debated practice. In theory, But the bigger code (avoids the function calls and returns by duplicating the code). However, many people have noticed that often using inlineing creates a slow code, the reason is that the code can be bigger and Its bone The size of the R can increase, one or more caches are used in run-time. As a result, some fraction of the function exits from the cache and through some loop it is remembered through each pass and through the cache And later reloading is more expensive than ever before than a function call. Another cache page. This is an interesting situation and can not be predicted, only by trial and error. "

Your collaborator needs to check the meaning of inlineing in C ++.

The word has two meanings, and this small to keep them separate virtual:

According to the C ++ standard, there is a function inline if it Inline is marked with the keyword, or the definition of class is defined in it.

Its only effect is to disable a definition rule - that is, in order to make it legal for definition in many translation units without causing a linker error. Basically, it allows you to put a full definition in a top file

then "inline" is customizable , instead of taking the function body, and instead inserting a function Call.

These meanings are almost completely orthogonal, whether or not a function can be inline by the compiler, whether you mark the programmer as inline . (Although hard work and less common for a compiler, if the function is defined in a separate translation unit which was defined in it) a function marked inline in C ++ Can not be inline or compiled by the compiler, the compiler tries to estimate its potential profit based on the code size, how many times the function is called, the number of call sites Received such heuristics result is that the compiler is when great that determine inlining Optimization is suitable, and your best bet is usually leave it alone your thing.

You just mark signs as inline when 1) It is convenient for you, and 2) You want to make sure that the option to implement inlineing optimization in the compiler Strong>.

But you are not compiling the compiler to inline anything, you are just arranging the code so that it can do this, the function can inline the call.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

jquery - SimpleModal Confirm fails to submit form -