Inline and template file extensions?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Koen

    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


  • Koen

    #2
    Re: Inline and template file extensions?

    Koen wrote:[color=blue]
    > 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[/color]

    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


    Comment

    • Luther Baker

      #3
      Re: Inline and template file extensions?

      "Koen" <no@ssppaamm.co m> wrote in message news:<c8f7kk$gl 9$1@gaudi2.UGen t.be>...[color=blue]
      > Koen wrote:[color=green]
      > > Hi,[/color][/color]
      ....[color=blue]
      >
      > 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)?[/color]

      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

      Comment

      • John Harrison

        #4
        Re: Inline and template file extensions?


        "Koen" <no@ssppaamm.co m> wrote in message
        news:c8f795$gft $1@gaudi2.UGent .be...[color=blue]
        > 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?
        >[/color]

        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


        Comment

        • Luther Baker

          #5
          Re: Inline and template file extensions?

          "John Harrison" <john_andronicu s@hotmail.com> wrote in message news:<2h3kc2F8g d95U1@uni-berlin.de>...[color=blue]
          > "Koen" <no@ssppaamm.co m> wrote in message
          > news:c8f795$gft $1@gaudi2.UGent .be...[color=green]
          > > 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?
          > >[/color]
          >
          > I would use .h for all of them.[/color]

          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.
          [color=blue]
          > Anything else is over elaboration I think.[/color]

          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

          Comment

          Working...