pragma once

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

    #16
    Re: pragma once

    "Julie" <julie@nospam.c om> wrote in message
    news:406F02C5.2 83F6763@nospam. com...[color=blue]
    > "<- Chameleon ->" wrote:[color=green]
    > > Use
    > > -----------------
    > > #ifndef __MY_HEADER_FIL E_H__
    > > #define __MY_HEADER_FIL E_H__[/color]
    >
    > Double-underscore identifiers are reserved for implementation purposes.[/color]
    Use[color=blue]
    > something like:
    >
    > #define MY_HEADER_FILE_ H
    >
    > instead.[/color]

    Indeed. Even a single leading underscore followed by a capital letter is
    reserved for implementors. Instead of remembering all these arcane rules,
    best not to use leading underscores at all.

    --
    Cy



    Comment

    • Jacob Jensen

      #17
      Re: pragma once

      For compiler efficiency reasons, that is all. It would be a very nice thing
      to have for me, and therefore I would like to find a good solution to my
      "problem".


      "Cy Edmunds" <cedmunds@spaml ess.rochester.r r.com> wrote in message
      news:CkEbc.1010 4$LW2.9792@twis ter.nyroc.rr.co m...[color=blue]
      > "Jacob Jensen" <jacob_news_dkN oSpaaaammmm@yah oo.co.uk> wrote in message
      > news:nCBbc.430$ KX.319@news.get 2net.dk...[color=green]
      > > But I want to use the pragma once directive with my microsoft compiler.[/color]
      >
      > This seems like a very strange requirement. Why?
      >
      > --
      > Cy
      > http://home.rochester.rr.com/cyhome/
      >
      >[/color]


      Comment

      • Jacob Jensen

        #18
        Re: pragma once

        For compiler efficiency reasons, that is all. It would be a very nice thing
        to have for me, and therefore I would like to find a good solution to my
        "problem".


        "Cy Edmunds" <cedmunds@spaml ess.rochester.r r.com> wrote in message
        news:CkEbc.1010 4$LW2.9792@twis ter.nyroc.rr.co m...[color=blue]
        > "Jacob Jensen" <jacob_news_dkN oSpaaaammmm@yah oo.co.uk> wrote in message
        > news:nCBbc.430$ KX.319@news.get 2net.dk...[color=green]
        > > But I want to use the pragma once directive with my microsoft compiler.[/color]
        >
        > This seems like a very strange requirement. Why?
        >
        > --
        > Cy
        > http://home.rochester.rr.com/cyhome/
        >
        >[/color]


        Comment

        • Julie

          #19
          Re: pragma once

          Jacob Jensen wrote:[color=blue]
          >
          > For compiler efficiency reasons, that is all. It would be a very nice thing
          > to have for me, and therefore I would like to find a good solution to my
          > "problem".
          >
          > "Cy Edmunds" <cedmunds@spaml ess.rochester.r r.com> wrote in message
          > news:CkEbc.1010 4$LW2.9792@twis ter.nyroc.rr.co m...[color=green]
          > > "Jacob Jensen" <jacob_news_dkN oSpaaaammmm@yah oo.co.uk> wrote in message
          > > news:nCBbc.430$ KX.319@news.get 2net.dk...[color=darkred]
          > > > But I want to use the pragma once directive with my microsoft compiler.[/color]
          > >
          > > This seems like a very strange requirement. Why?
          > >
          > > --
          > > Cy
          > > http://home.rochester.rr.com/cyhome/
          > >
          > >[/color][/color]

          If you are after efficiency (compilation speed?), look into precompiled
          headers.

          Comment

          • Julie

            #20
            Re: pragma once

            Jacob Jensen wrote:[color=blue]
            >
            > For compiler efficiency reasons, that is all. It would be a very nice thing
            > to have for me, and therefore I would like to find a good solution to my
            > "problem".
            >
            > "Cy Edmunds" <cedmunds@spaml ess.rochester.r r.com> wrote in message
            > news:CkEbc.1010 4$LW2.9792@twis ter.nyroc.rr.co m...[color=green]
            > > "Jacob Jensen" <jacob_news_dkN oSpaaaammmm@yah oo.co.uk> wrote in message
            > > news:nCBbc.430$ KX.319@news.get 2net.dk...[color=darkred]
            > > > But I want to use the pragma once directive with my microsoft compiler.[/color]
            > >
            > > This seems like a very strange requirement. Why?
            > >
            > > --
            > > Cy
            > > http://home.rochester.rr.com/cyhome/
            > >
            > >[/color][/color]

            If you are after efficiency (compilation speed?), look into precompiled
            headers.

            Comment

            • Mike Smith

              #21
              Re: pragma once

              Jacob Jensen wrote:
              [color=blue]
              > But I want to use the pragma once directive with my microsoft compiler.[/color]

              Why, when there is a perfectly good, cross-platform, widely-used
              convention (i.e. include guards) already out there?

              --
              Mike Smith

              Comment

              • Mike Smith

                #22
                Re: pragma once

                Jacob Jensen wrote:
                [color=blue]
                > But I want to use the pragma once directive with my microsoft compiler.[/color]

                Why, when there is a perfectly good, cross-platform, widely-used
                convention (i.e. include guards) already out there?

                --
                Mike Smith

                Comment

                • Bill Seurer

                  #23
                  Re: pragma once

                  Jacob Jensen wrote:
                  [color=blue]
                  > For compiler efficiency reasons, that is all. It would be a very nice thing
                  > to have for me, and therefore I would like to find a good solution to my
                  > "problem".[/color]

                  I've looked through all the postings and I'm not clear either what the
                  problem is or what pragma once does (and, therefore, how it is supposed
                  to help).

                  In general pragmas are completely non-portable. Avoid them if at all
                  possible.

                  Comment

                  • Bill Seurer

                    #24
                    Re: pragma once

                    Jacob Jensen wrote:
                    [color=blue]
                    > For compiler efficiency reasons, that is all. It would be a very nice thing
                    > to have for me, and therefore I would like to find a good solution to my
                    > "problem".[/color]

                    I've looked through all the postings and I'm not clear either what the
                    problem is or what pragma once does (and, therefore, how it is supposed
                    to help).

                    In general pragmas are completely non-portable. Avoid them if at all
                    possible.

                    Comment

                    • Mike Smith

                      #25
                      Re: pragma once

                      Bill Seurer wrote:
                      [color=blue]
                      > Jacob Jensen wrote:
                      >[color=green]
                      >> For compiler efficiency reasons, that is all. It would be a very nice
                      >> thing
                      >> to have for me, and therefore I would like to find a good solution to my
                      >> "problem".[/color]
                      >
                      >
                      > I've looked through all the postings and I'm not clear either what the
                      > problem is or what pragma once does (and, therefore, how it is supposed
                      > to help).[/color]

                      #pragma once does more or less exactly what include guards do; i.e.
                      prevent a header form being included more than once for any given
                      translation unit. There is no reason whatsoever (except for somewhat
                      less typing) to use #pragma once instead of include guards.

                      --
                      Mike Smith

                      Comment

                      • Mike Smith

                        #26
                        Re: pragma once

                        Bill Seurer wrote:
                        [color=blue]
                        > Jacob Jensen wrote:
                        >[color=green]
                        >> For compiler efficiency reasons, that is all. It would be a very nice
                        >> thing
                        >> to have for me, and therefore I would like to find a good solution to my
                        >> "problem".[/color]
                        >
                        >
                        > I've looked through all the postings and I'm not clear either what the
                        > problem is or what pragma once does (and, therefore, how it is supposed
                        > to help).[/color]

                        #pragma once does more or less exactly what include guards do; i.e.
                        prevent a header form being included more than once for any given
                        translation unit. There is no reason whatsoever (except for somewhat
                        less typing) to use #pragma once instead of include guards.

                        --
                        Mike Smith

                        Comment

                        • Julie

                          #27
                          Re: pragma once

                          Mike Smith wrote:[color=blue]
                          > #pragma once does more or less exactly what include guards do; i.e.
                          > prevent a header form being included more than once for any given
                          > translation unit. There is no reason whatsoever (except for somewhat
                          > less typing) to use #pragma once instead of include guards.[/color]

                          I'd suspect that #pragma once would be more efficient during subsequent
                          inclusions as the pre-processor could terminate the parse and close the file at
                          that point.

                          With an include guard, the entire file must still be parsed.

                          As I previously mentioned, the best solution for inclusion performance is using
                          pre-compiled headers.

                          However, both (#pragma once and pch) are compiler-specific issues, and can be
                          better answered in a forum dealing with the specifics of the OPs compiler.

                          The only platform-neutral option is include guards.

                          Comment

                          • Julie

                            #28
                            Re: pragma once

                            Mike Smith wrote:[color=blue]
                            > #pragma once does more or less exactly what include guards do; i.e.
                            > prevent a header form being included more than once for any given
                            > translation unit. There is no reason whatsoever (except for somewhat
                            > less typing) to use #pragma once instead of include guards.[/color]

                            I'd suspect that #pragma once would be more efficient during subsequent
                            inclusions as the pre-processor could terminate the parse and close the file at
                            that point.

                            With an include guard, the entire file must still be parsed.

                            As I previously mentioned, the best solution for inclusion performance is using
                            pre-compiled headers.

                            However, both (#pragma once and pch) are compiler-specific issues, and can be
                            better answered in a forum dealing with the specifics of the OPs compiler.

                            The only platform-neutral option is include guards.

                            Comment

                            Working...