473,797 Members | 3,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5593
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.co m> wrote in message news:<c8******* ***@gaudi2.UGen t.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.co m> 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.co m> 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
10121
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 certainly the one I use. This leaves me with a question. As example, consider the following class. template<class T> class foo
7
2699
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> using namespace std; template<class T, int size = 50> class Stack {
6
4009
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 as well. To support thin-template, I need to make virtual function as inline. Now, I know that compiler would generate an out-of-line copy when it
9
1534
by: GJ | last post by:
The performance can be DEGRADED by making a function "inline". Is it TRUE in any case ? -- GJ
30
19758
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 possible. ---------- Will Pittenger E-Mail: mailto:will.pittenger@verizon.net All mail filtered by Qurb (www.qurb.com)
6
2110
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 function should not be written in the C++ file? Or what are the disadvantages of inline function body in a C++ file? -- Regards Sharon G.
4
2643
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 from all classes within the header file are included via a separate file, at the end of the file, with a directive of the form: #include <foo.inl>
32
2097
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
8386
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 the function if possible" (because if the compiler has the function definition available at an instantiation point, it will estimate whether to inline it or not, and do so if it estimates it would be beneficial, completely regardless of whether...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9537
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10469
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10023
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4135
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3750
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2934
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.