Sign in to follow this  

inline Files linkage problem...

This topic is 4305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I am trying to introduce using inline files into my projects. The main reason reduce the number of files that have to rebuilt when one gets altered. Cureently my inline functions are declared within the class so any change is quite painful. Anyways my reserach has made me aware of two appoaches so far. The first to just include the inline file at the bottom of the header....doesn't seem so great to me since its effectivly one file but slightly cleaner to look at. The second was to just include the inline file in any source files that need it. Still doesnt seem perfect because it means a lot more 'include' directives in sources files and those will have to be rebuilt if there are any changes... Do you think it might be better just to define all inline functions at the bottom of the source file...? Or perhaps only define private inline functions in the inline file and the rest in the class header? I hope you can offer a more elegant solution than I have been able to come up with... Thanks in advance :)

Share this post


Link to post
Share on other sites
hmm.....no takers.

Well, can someone please tell me why it is that to inlude a class (declared in a header, functions defined in a .cpp source) into another source file just the header needs to be 'included'. Yet when I have a class (declared in header, functions defined in in a .cpp source and inline functions defined in a .inl file) I need to 'include' both the header and the .inl file?

I thought all the other classes that need to know about this class would only need the header for the declarations....

Share this post


Link to post
Share on other sites
Quote:

I am trying to introduce using inline files into my projects. The main reason reduce the number of files that have to rebuilt when one gets altered.


Inline functions actually increase the "number of files that have to rebuilt". This is because they must be visible in the source of the class that is calling them. Every time you compile a "client" of that class, you are recompiling the inline functions.

Quote:

Well, can someone please tell me why it is that to inlude a class (declared in a header, functions defined in a .cpp source) into another source file just the header needs to be 'included'. Yet when I have a class (declared in header, functions defined in in a .cpp source and inline functions defined in a .inl file) I need to 'include' both the header and the .inl file?


The compiler must see the source to an inline function where it is used, if it is to be inlined.

It is more idiomatic to actaully place the inline the functions in the header, not in a separate .inl file...

The most elegant solution is not to use inlines, except for really trivial code, eg ( getAge() { return age; } )

Good Luck!

Share this post


Link to post
Share on other sites
wow...that was very helpful for me...thank you :)

Basically all of my inline functions are extremenly trivial...but still its a pain to change something although after reading what your wrote I guess it is probably easier to leave things as they were...


[Edited by - bobbinus on March 2, 2006 8:47:17 PM]

Share this post


Link to post
Share on other sites

This topic is 4305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this