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. pragma once

pragma once

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
4 Posts 3 Posters 5 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.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    If I put pragma once in all my .h files that is sufficient to prevent any include multile definition problems right? Is this the same thing as doing #ifndef #define #endif that we see in the MFC .h generated files? If so , pragma once is much easier, so why isnt that used by t he Class wizard instead of the ifndef stuff? Appreciate your help, ns

    L J 2 Replies Last reply
    0
    • N ns

      If I put pragma once in all my .h files that is sufficient to prevent any include multile definition problems right? Is this the same thing as doing #ifndef #define #endif that we see in the MFC .h generated files? If so , pragma once is much easier, so why isnt that used by t he Class wizard instead of the ifndef stuff? Appreciate your help, ns

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      In VC7, generated headers have only the #pragma once line. My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers

      1 Reply Last reply
      0
      • N ns

        If I put pragma once in all my .h files that is sufficient to prevent any include multile definition problems right? Is this the same thing as doing #ifndef #define #endif that we see in the MFC .h generated files? If so , pragma once is much easier, so why isnt that used by t he Class wizard instead of the ifndef stuff? Appreciate your help, ns

        J Offline
        J Offline
        Joaquin M Lopez Munoz
        wrote on last edited by
        #3

        As you say, both alternatives are equivalent. #pragma once, on the other hand, is not standard C or C++, so in general I prefer the #ifndef guard. As MS guys usually don't bother about standard compliance, I guess they don't use #pragma once only for historical reasons. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

        N 1 Reply Last reply
        0
        • J Joaquin M Lopez Munoz

          As you say, both alternatives are equivalent. #pragma once, on the other hand, is not standard C or C++, so in general I prefer the #ifndef guard. As MS guys usually don't bother about standard compliance, I guess they don't use #pragma once only for historical reasons. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

          N Offline
          N Offline
          ns
          wrote on last edited by
          #4

          I shall start using pragma since upto now I didnt do any guard at all....leading to dreaded multiple include issues... Appreciate your help, ns

          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