RE: [Doxygen-users] (no subject)
Brought to you by:
dimitri
From: Kris T. <kri...@cs...> - 2002-01-16 18:17:22
|
Hi Paul, > > Kris, Victor, > > Thanks, but I don't know if I agree with what has been > > said. Maybe you should read a good C++ book then! This is not a doxygen question by the way, so I don't think we should be discussion this further on this list (after this email of course!) > In the first case (below), I assume we all > agree > that even though I did not explicitly say 'inline', > the compiler might choose to inline a method. > As far as syntax goes, in the first case you can put inline in there or not, syntactically it means exactly the same: it's an 'inline' method. This doesn't say anything at all about what code the compiler will generate (even with an explicit inline, it doesn't have to inline it). It does say something about how the compiler should handle linking etc. In particular, a function/method declared as inline can occur in multiple object files, while a non-inline (and non-static) one cannot. > But my second case is very similar - the definitions > are still in the header file, they are simple placed > outside the main class declaration. So why should the > compiler not choose to inline them anyway? After all > all the information is still there, in the header > file, > at compile time. > You have to remember that the actual compiler actually never sees your header file, it only sees the preprocessed thing, which has the header files and your .cpp file merged into 1 huge text file. > Now there may be a reason it doesn't do this, which > is what my question is about. But I cannot see that > my use of the 'inline' keyword is going to > help. This is just a suggestion, after all, not > binding on the compiler. Is there a hard rule > somewhere that if the method definition is separate > from the method declaration, but still in the include > file, it will not be inlined unless 'inline' is used? > Depends what you mean. Syntactically, the only ways to get it the status of an inline function are - put it in the class definition - add inline to its function declaration If at some point, the compiler needs to fill in the function call, it can choose to inline or not, depending on your suggestion and what it thinks is best. That's independent of the above. (For example, you might have a non-inline function which you call in the same object file as its definition. The compiler might choose to inline that function call). I guess here's the difference. You can have an inline function, or the compiler can inline a function call. They're largely (but hopefully not completely) independent of each other. I hope this clarifies the issue. If not, I'd be willing to discuss this off the list, although I'm not sure what other words I can use. You might be better off in alt.languages.C++ or so. All the best, Kris |