Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. why it is so..

why it is so..

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
11 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R ramina sen

    why in mfc programming # prgma once is used??

    C Offline
    C Offline
    Code o mat
    wrote on last edited by
    #2

    To avoid multiple inclusion of the same header file. This used to be like this:

    #ifndef MY_HEADER_FILE_H__
    #define MY_HEADER_FILE_H__

    ...

    #endif

    But using pragma once makes it easier.

    > The problem with computers is that they do what you tell them to do and not what you want them to do. <

    M 1 Reply Last reply
    0
    • R ramina sen

      why in mfc programming # prgma once is used??

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #3

      Pragma once is used to include the header file only one time when compiling. No sense in having to parse through the same header file multiple times.

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

      C 1 Reply Last reply
      0
      • C Code o mat

        To avoid multiple inclusion of the same header file. This used to be like this:

        #ifndef MY_HEADER_FILE_H__
        #define MY_HEADER_FILE_H__

        ...

        #endif

        But using pragma once makes it easier.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. <

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #4

        Code-o-mat wrote:

        But using pragma once makes it easier.

        but not portable, it's a Microsoft specific pragma (as far as I know).

        C N L T 4 Replies Last reply
        0
        • M Maximilien

          Code-o-mat wrote:

          But using pragma once makes it easier.

          but not portable, it's a Microsoft specific pragma (as far as I know).

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #5

          As far as i know you are right.

          > The problem with computers is that they do what you tell them to do and not what you want them to do. <

          1 Reply Last reply
          0
          • M Maximilien

            Code-o-mat wrote:

            But using pragma once makes it easier.

            but not portable, it's a Microsoft specific pragma (as far as I know).

            N Offline
            N Offline
            Nemanja Trifunovic
            wrote on last edited by
            #6

            Recent versions of GNU compiler also support it.

            Programming Blog utf8-cpp

            1 Reply Last reply
            0
            • R ramina sen

              why in mfc programming # prgma once is used??

              CPalliniC Offline
              CPalliniC Offline
              CPallini
              wrote on last edited by
              #7

              Bisua wrote:

              # prgma once

              To irritate the compiler. #pragma once is not MFC specific and is even documented :rolleyes: [^]. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
              [My articles]

              In testa che avete, signor di Ceprano?

              1 Reply Last reply
              0
              • M Maximilien

                Code-o-mat wrote:

                But using pragma once makes it easier.

                but not portable, it's a Microsoft specific pragma (as far as I know).

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #8

                Maximilien wrote:

                it's a Microsoft specific pragma (as far as I know).

                My bad, I mistook you for the original poster! I am officially embarrassed :-O

                led mike

                1 Reply Last reply
                0
                • M Maximilien

                  Code-o-mat wrote:

                  But using pragma once makes it easier.

                  but not portable, it's a Microsoft specific pragma (as far as I know).

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #9

                  so are MFC, so it doesn't matter in this case :)

                  [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                  1 Reply Last reply
                  0
                  • P Paul Conrad

                    Pragma once is used to include the header file only one time when compiling. No sense in having to parse through the same header file multiple times.

                    "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

                    C Offline
                    C Offline
                    Code o mat
                    wrote on last edited by
                    #10

                    ...not to mention the nice "redeclaration" and "multiple definition" errors you'd get.

                    > The problem with computers is that they do what you tell them to do and not what you want them to do. <

                    CPalliniC 1 Reply Last reply
                    0
                    • C Code o mat

                      ...not to mention the nice "redeclaration" and "multiple definition" errors you'd get.

                      > The problem with computers is that they do what you tell them to do and not what you want them to do. <

                      CPalliniC Offline
                      CPalliniC Offline
                      CPallini
                      wrote on last edited by
                      #11

                      Code-o-mat wrote:

                      ...not to mention the nice "redeclaration" and "multiple definition" errors you'd get.

                      or even recursive inclusion ;)

                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                      [My articles]

                      In testa che avete, signor di Ceprano?

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups