-1

I was reading and came across the #pragma directive, so I decided to do some research. However, I didn't understand much and would like to see if someone can shortly explain it to me about the #pragma directive, because I don't understand the websites about it like cppreference, suggested by wohlstad, and I am just a beginner in C++. Thanks for any help!

(Edit: I saw a comment by Botje about what comes after #pragma, but I just want to know all of its uses so that I can use it in the future.)

17
  • 8
    depends on what word comes after #pragma...
    – Botje
    Commented Dec 10 at 13:29
  • 7
    It's always compiler specific. There are few "common" pragmas, but even those you have to verify with your compiler first. en.cppreference.com/w/cpp/preprocessor/impl Commented Dec 10 at 13:34
  • 2
    Codeblocks is a proram to edit source code, it is not the compiler itself. So you will still need to find out what compiler your install is using. Commented Dec 10 at 14:07
  • 3
    In general, don't use it. It has no portable semantics; it's entirely up to the compiler writer to decide what it means. Commented Dec 10 at 14:17
  • 2
    @jabaa -- "I don't know of any ..." isn't the same as "there are no ...". But what, exactly, is the specification for #pragma once? Is an exact duplicate of a file, in a different location, "the same"? Is a file on a network, reached through a path that traverses different servers, easily recognizable a "the same"? There's no way to know, within the code you write, whether two #include directives will satisfy #pragma once; with include guards (correctly written, of course) you know exactly what you're getting. Commented Dec 10 at 14:33

0

Browse other questions tagged or ask your own question.