473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Inline and template file extensions?

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
4 5550
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
"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

"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Williams | last post by:
The common method of defining template classes and functions is to put the definition and declaration into the same header file. Or at least I believe it to be the common method and it is...
7
by: Senthilraja | last post by:
I have the following program using templates. Someone please let me know the syntax to be used for defining the member functions push, pop etc. as non-inline functions. #include <iostream>...
6
by: RainBow | last post by:
Greetings!! I introduced the so-called "thin-template" pattern for controlling the code bloat caused due to template usage. However, one of the functions in the template happens to be virtual...
9
by: GJ | last post by:
The performance can be DEGRADED by making a function "inline". Is it TRUE in any case ? -- GJ
30
by: Will Pittenger | last post by:
Does C# inline functions? I do not see a inline keyword. Is there an implicit inline? Can the compiler select functions for auto-inlining? I am more used to C++ where all these things are...
6
by: Sharon | last post by:
Usually it is common to write the class member function in the class H file, but some people like to write the function body in the C++ file. Can anybody tell me what are the cases where inline...
4
by: John Goche | last post by:
Hello, I have been going through several header source files which define classes with inline functions. In the case where the inline functions are not defined in place, the inline functions...
32
by: Immortal Nephi | last post by:
I want to know if the practice is the best. Do I need to place inline keyword inside class definition or outside member function definition. For example class A { public: A(); ~A();
17
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.