On Tuesday, April 3, 2012 at 10:41:37 PM UTC+2, Kyle Huey wrote:
> That's true for things at file scope, yes.  My not-very-random sample of
> MXR indicates that this is often used on static things on structs/classes,
> which has an entirely different meaning of course.
> 
> - Kyle

Static Inline makes perfectly sense in C++

Consider the following use case: (in principle I think its irrelevant if the 
function is static or not)
You have a library/DLL for which you in some case wants to link in the library 
whereas for other occasions you just want to use a small set of functions, and 
for this you use the inlined versions to avoid the hassle of having to ship 
also the DLL. 

The decision on whether to use the inlined version or the the DLL (the code 
should be the same) is taken by the compiler. If the "inline" keyword is not 
used then the implementation will be taken form the DLL wg\hen generating the 
object files, even if the implementation is present in the header file.

Now, when linking, you will get an error of the form "XYZ allready defined 
in....." Because the function is implemented multiple places, firstly, in the 
DLL, the in every place where the header file containing the function is 
included.

Using "inline" will only be necessary in front of the implementation, however 
in my opinion it is a good idea to add inline also in form of the function 
definition in order to show intent, even if the keyword has no effect.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to