Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2006
    Posts
    23

    #pragma once vs #ifndef...

    I have been working through all the VTM's and such and now I'm starting to make mine own little games and I was wondering what the difference is between using #pragma once or useing #ifndef...#define....#endif which is what they use in the VTMs? I know it may be simple but I was just wondering.

  2. #2
    Join Date
    Mar 2004
    Posts
    0
    #pragame statments are compiler-spacific. I belive that #pargma once only works on VC++. However, #pragma once is faster then the #define method, becuse VC++ dosn't even look into the file, saving times on massive builds.

    I would suggest using the #define method. If you end up writing software that is hundreds of header files big, then it is simple to write a small script that adds #pragma once to all the files, but untill then, it's better to use #define for compatibility...



  3. #3
    Join Date
    Oct 2006
    Posts
    23
    That makes sense. Thanks for the information.

  4. #4
    Join Date
    Feb 2005
    Location
    Bellevue, WA
    Posts
    3,251
    FYI, #pragma once is deemed to be 'obsolete' by gcc but supported.

    Also, gcc actually has some performance improvements around #ifndef that I don't believe the MS C++ compiler has. So your compile time may vary depending on the compiler you use and if you optimize for compatibility vs. compiler specific features.

    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." ~Rich Cook

  5. #5
    Join Date
    Jul 2006
    Posts
    10
    I believe #pragma has been declared deprected by the GCC.

  6. #6
    Join Date
    Jul 2006
    Posts
    10
    lol, jynx!

  7. #7
    Join Date
    Feb 2005
    Location
    Bellevue, WA
    Posts
    3,251
    Quote Originally Posted by Seifsta
    lol, jynx!
    Hehe... no way, my timestamp is a minute before you.

    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." ~Rich Cook

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •