Thread: #pragma

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    86

    #pragma

    what does the #pragma preprocessor command do?

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    It is used to change the rules by which your code is compiled/linked. Some common directives issued are to turn off or enable warnings, change the default struct packing rules, force inclusion of libraries when linking, and enable/disable optimizations around certain code segments.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    They're also very non-portable, being as they are specific to each compiler.

    #pragma foo
    might do very different things of different compilers.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

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