T
Tony Johansson
Hello experts!
I'm reading a book about C++ and there is something about inline that the
book says that is unclear for me.
The book says the following "Because inline functions are expanded at
compile time, definitions of these
functions, unlike other definitions, cannot be separately compiled and must
be placed in header files.
This creates a problem if the compiler does not actually inline a
funktion(you may end up having multiple definitions of the same function).
Therefore, you have to check that the inline functions will actually be
inlined, and if they
cannot be inlined, you must remove the inline specification."
Here is the question about the text above that has been extracted from the
book. I understand the first sentence but not the second sentence. It says
"This creates a problem if the compiler does not actually inline a
funktion(you may end up having multiple definitions of the same function)".
I'don't understand how it is possible to end up with two definitions?
Sentence three says "Therefore, you have to check that the inline functions
will actually be inlined, and if they
cannot be inlined, you must remove the inline specification.". How can I
check that a function is really inlined?
Many thanks!!
//Tony
I'm reading a book about C++ and there is something about inline that the
book says that is unclear for me.
The book says the following "Because inline functions are expanded at
compile time, definitions of these
functions, unlike other definitions, cannot be separately compiled and must
be placed in header files.
This creates a problem if the compiler does not actually inline a
funktion(you may end up having multiple definitions of the same function).
Therefore, you have to check that the inline functions will actually be
inlined, and if they
cannot be inlined, you must remove the inline specification."
Here is the question about the text above that has been extracted from the
book. I understand the first sentence but not the second sentence. It says
"This creates a problem if the compiler does not actually inline a
funktion(you may end up having multiple definitions of the same function)".
I'don't understand how it is possible to end up with two definitions?
Sentence three says "Therefore, you have to check that the inline functions
will actually be inlined, and if they
cannot be inlined, you must remove the inline specification.". How can I
check that a function is really inlined?
Many thanks!!
//Tony