Inline and template file extensions?

K

Koen

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
 
K

Koen

Koen said:
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
 
L

Luther Baker

Koen said:
....

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
 
J

John Harrison

Koen said:
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
 
L

Luther Baker

John Harrison said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top