By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,169 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,169 IT Pros & Developers. It's quick & easy.

Inline and template file extensions?

P: n/a
Hi,

I was wondering if there are standard conventions about the extensions
to be used for files that contain:
(1) inline implementations
(2) template implementations
(3) inline template implementations
It seems like most people use .inl for (1) and some use .tpl for (2),
but I only find 1 reference to .tnl files for (3).
So, any standards/conventions for these?

Koen
Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Koen wrote:
Hi,

I was wondering if there are standard conventions about the extensions
to be used for files that contain:
(1) inline implementations
(2) template implementations
(3) inline template implementations


Come to think of it: since template implementations are always inlined
(correct me if I'm wrong), maybe it makes sense to consider template
implementations as inline code tout court (so also use .inl instead of
..tpl)? Or is there a reason why I should still consider them as separate
things (and keep the .inl and .tpl distinction)?

Koen
Jul 22 '05 #2

P: n/a
"Koen" <no@ssppaamm.com> wrote in message news:<c8**********@gaudi2.UGent.be>...
Koen wrote:
Hi,
....
Come to think of it: since template implementations are always inlined
(correct me if I'm wrong), maybe it makes sense to consider template
implementations as inline code tout court (so also use .inl instead of
.tpl)? Or is there a reason why I should still consider them as separate
things (and keep the .inl and .tpl distinction)?


I seem to remember that MS uses .inl extensions for some type of file.
So in an effort to keep it more C++ish, I try to use the common .hpp,
..hxx and .cpp extensions.

hpp is normally a C++ header file
hxx is usually has inlinable (or template impl) code
cpp is generally the implementation

If you really need flexibility, use a macro in place of the keyword
'inline' and at compilation time, (via macros again) you can include
the .hxx content in either the header or implementation file, inlined
or not per your INLINE macro.

At any rate, these decisions are arbitrary - but easy to remember and
great at keeping Emacs a happy camper.

Hth,

-Luther
Jul 22 '05 #3

P: n/a

"Koen" <no@ssppaamm.com> wrote in message
news:c8**********@gaudi2.UGent.be...
Hi,

I was wondering if there are standard conventions about the extensions
to be used for files that contain:
(1) inline implementations
(2) template implementations
(3) inline template implementations
It seems like most people use .inl for (1) and some use .tpl for (2),
but I only find 1 reference to .tnl files for (3).
So, any standards/conventions for these?


I would use .h for all of them. The most important distinction is between
files that are directly compiled and those that are included. At a push I
might be prepared to use .hpp for C++ headers and .h for C compatible
headers.

Anything else is over elaboration I think.

john
Jul 22 '05 #4

P: n/a
"John Harrison" <jo*************@hotmail.com> wrote in message news:<2h************@uni-berlin.de>...
"Koen" <no@ssppaamm.com> wrote in message
news:c8**********@gaudi2.UGent.be...
Hi,

I was wondering if there are standard conventions about the extensions
to be used for files that contain:
(1) inline implementations
(2) template implementations
(3) inline template implementations
It seems like most people use .inl for (1) and some use .tpl for (2),
but I only find 1 reference to .tnl files for (3).
So, any standards/conventions for these?

I would use .h for all of them.


Hi John,

It follows from your suggestion, (assuming the OP's original goal to
separate the header and inline implementation) that you'd have to
rename the inline implementation file since both the header and
inline/template implementation files would use the .h extension.

So, either you're arguing for

a) *not* separating inline or template implementations from the
header in which they are declared - thereby keeping them in the same
file.

b) or you don't mind using new file names for related header and
inline/template implementations.

Regarding these two suggestions:

a) I think the OP's question was asking for good name suggestions
for separate header and inline files. Just to be clear, your
suggestion says "don't do it". See below.

b) I don't think you're arguing for this - but an additional name
for inline implementation files doesn't seem any better than using a
different postfix, such as those the poster originally suggested. IE:
somestuff.h, somestuff-inline.h, somestuff.cpp doesn't seem to fix
anything.
Anything else is over elaboration I think.


Thats a pretty broad generalization. Different projects have different
requirements. The ACE Networking Library separates potential inline
implementations for reasons I stated in an early post. Sometimes
implementations need to compile with the .cpp files -- and other times
the implementation can be inlined and included with the .h file.
Depends on the context/requirements.

-Luther
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.