#pragma once

This is a discussion on #pragma once within the C++ Programming forums, part of the General Programming Boards category; what does "#pragma once" mean?...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    266

    #pragma once

    what does "#pragma once"
    mean?

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    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
    Posts
    4,913
    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, 03:23 PM
  3. what does #pragma do?
    By cbc in forum C++ Programming
    Replies: 2
    Last Post: 10-16-2003, 07: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21