Thread: #pragma once

  1. #1
    Registered User
    Join Date
    Aug 2005

    #pragma once

    what does "#pragma once"

  2. #2

  3. #3
    Registered User
    Join Date
    Apr 2003
    It makes sure a header file is only included once per file. If header files are included more than once in the same file, you will get a bunch of errors. I believe it's MS specific though, so I don't think it is the recommended method for ensuring header files are only included once. Use #ifndef--#endif inclusion guards instead.

  4. #4
    Super Moderator
    Join Date
    Sep 2001
    All the preprocessor directives have a standard usage in the standard - like #define, #include, etc... but #pragma is set aside to be used by your implemenation for any miscellaneous purpose - so if you ever need to know the meaning of a line beginning with #pragma, the place to look is your compiler documentation. In this case, Microsoft.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. labels inside the code #pragma mark label
    By nacho4d in forum C++ Programming
    Replies: 6
    Last Post: 01-11-2009, 02:50 AM
  2. Programming a PIC 16F84 microcontroller in C
    By Iahim in forum C Programming
    Replies: 1
    Last Post: 05-13-2004, 02:23 PM
  3. what does #pragma do?
    By cbc in forum C++ Programming
    Replies: 2
    Last Post: 10-16-2003, 06:51 AM
  4. #pragma ?
    By dat in forum C++ Programming
    Replies: 2
    Last Post: 04-02-2003, 08:14 AM
  5. what is a pragma comment?
    By Shadow12345 in forum C++ Programming
    Replies: 9
    Last Post: 11-25-2002, 05:50 AM