Inline and template file extensions?

Discussion in 'C++' started by Koen, May 19, 2004.

  1. Koen

    Koen Guest

    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
     
    Koen, May 19, 2004
    #1
    1. Advertising

  2. Koen

    Koen Guest

    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
     
    Koen, May 19, 2004
    #2
    1. Advertising

  3. Koen

    Luther Baker Guest

    "Koen" <> wrote in message news:<c8f7kk$gl9$>...
    > 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
     
    Luther Baker, May 19, 2004
    #3
  4. "Koen" <> wrote in message
    news:c8f795$gft$...
    > 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
     
    John Harrison, May 20, 2004
    #4
  5. Koen

    Luther Baker Guest

    "John Harrison" <> wrote in message news:<>...
    > "Koen" <> wrote in message
    > news:c8f795$gft$...
    > > 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
     
    Luther Baker, May 20, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abhi
    Replies:
    2
    Views:
    766
    E. Robert Tisdale
    Jul 3, 2003
  2. Alvin
    Replies:
    7
    Views:
    511
    E. Robert Tisdale
    May 6, 2005
  3. Sean
    Replies:
    4
    Views:
    693
    Rolf Magnus
    Apr 30, 2006
  4. Rahul
    Replies:
    3
    Views:
    480
    James Kanze
    Feb 28, 2008
  5. Sven Wolf
    Replies:
    7
    Views:
    223
    Tad McClellan
    Dec 3, 2004
Loading...

Share This Page