Questions tagged [pragma]

The #pragma directives offer a way for each compiler to offer machine- and operating system-specific features while retaining overall compatibility with the C and C++ languages.

Each implementation of C and C++ supports some features unique to its host machine or operating system. Some programs, for instance, need to exercise precise control over the memory areas where data is placed or to control the way certain functions receive parameters. The #pragma directives offer a way for each compiler to offer machine- and operating system-specific features while retaining overall compatibility with the C and C++ languages. Pragmas are machine- or operating system-specific by definition, and are usually different for every compiler.

From MSDN

761 questions
22
votes
2 answers

How do I define a macro with multiple pragmas for Clang?

I'd like to add some macros to ease (un)setting a specific warning around routines that we are deprecating internally. I'd like to turn this: #pragma clang diagnostic push #pragma clang diagnostic warning "-Wdeprecated-declarations" void Foo()…
fbrereto
  • 35,429
  • 19
  • 126
  • 178
22
votes
2 answers

Xcode - Using #pragma mark

I'm pretty sure this isn't a duplicate. Do you use #pragma mark? I've seen multiple ways, which is correct? #pragma mark - #pragma mark === Actions === #pragma mark - #pragma mark - #pragma mark === Actions === #pragma mark - === Actions…
mk12
  • 25,873
  • 32
  • 98
  • 137
21
votes
13 answers

#pragma mark not showing in methods in Xcode 4.0

In Xcode Version 4.0 I notice that #pragma marks within methods are no longer showing up in the Jump Bar. The only #pragma marks that are showing up are those that are between methods. I was using these #pragma marks to make it easy to quickly…
Aikitect
  • 211
  • 2
  • 3
21
votes
2 answers

#pragma mark not listing the first group name

I'm using #pragma mark for grouping my methods under certain categories. But the issue is in Xcode 4 my first category is not displaying. My code looks like: @interface MyClass : NSObject #pragma mark - #pragma mark Category 1 //Some method…
Midhun MP
  • 103,496
  • 31
  • 153
  • 200
21
votes
7 answers

How to disable a specific nvcc compiler warnings

I want to disable a specific compiler warning with nvcc, specifically warning: NULL reference is not allowed The code I am working on uses NULL references are part of SFINAE, so they can't be avoided. An ideal solution would be a #pragma in just…
bcumming
  • 1,075
  • 2
  • 8
  • 17
20
votes
6 answers

Any way to group methods in Java/Eclipse?

I would like to be able to group similar methods and have them appear in my Outline view in Eclipse. This makes navigating large swaths of code a little easier on the eye, and easier to find methods you need. In Objective-C there was a pragma mark…
Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
20
votes
3 answers

How to change optimization level of one function?

This is related to Determine cause of segfault when using -O3? In the question, I'm catching a segfault in a particular function when compiled with -O3 using a particular version of GCC. At -O3, vectorization instructions are used (at -O2, they are…
jww
  • 97,681
  • 90
  • 411
  • 885
19
votes
1 answer

What does '#pragma GCC optimize ("O3")' mean?

I came through this line in project source code written before a function. I want to know, what is the use of it ? #pragma GCC optimize ("O3") void somefunction() { .... } Requesting to explain every argument used in the directive. Thanks and…
Madhu R
  • 345
  • 1
  • 4
  • 9
19
votes
1 answer

pragma pack(1) nor __attribute__ ((aligned (1))) works

My code used to work in the past, but now the struct size suddenly is 16 bytes. It used to be 13 bytes. I recently upgraded from Xcode 4.2 to Xcode 4.3.1 (4E1019). #pragma pack(1) struct ChunkStruct { uint32_t width; uint32_t height; …
neoneye
  • 50,398
  • 25
  • 166
  • 151
18
votes
5 answers

What is the reason for #pragma once inside header guards?

Just seen this inside #ifndef BOOST_ASIO_HPP #define BOOST_ASIO_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) /// .... #endif // BOOST_ASIO_HPP Disregarding the…
dubnde
  • 4,359
  • 9
  • 43
  • 63
16
votes
2 answers

In SQLite3, is there a foreignkey integrity check?

My foreign_key constraint was not working when I was able to delete a parent entry. The pragma for foreign_key is off by default for each session. Seems odd there isn't a resource file (like .exrc for vi) to setup pragmas by default for each…
Eradicatore
  • 1,501
  • 2
  • 20
  • 38
16
votes
3 answers

#pragma mark equivalent in Visual Studio for C++?

Is there a Visual Studio preprocessor equivalent of #pragma mark found in XCode? Here's why I ask: This is on Windows. This is on Mac. I know of #region in C#, but nothing of similar functionality in C++. EDIT 12/03/2013: #pragma region adds…
KillAWatt1705
  • 645
  • 1
  • 6
  • 13
15
votes
6 answers

Is there a pragma directive for include directories?

As the title says: Is there a pragma directive for include directories using VS20** C++? I think about something like: #pragma comment(include, "..\externals\blah\includes\") So that I can use includes in this style, and blah.h also can use this…
Christoph Meißner
  • 1,511
  • 2
  • 21
  • 40
15
votes
3 answers

Can I change static variable initialization order in C++?

I use C++ in Visual Studio 2015 sp3. By #pragma init_seg(compiler) , I initialize some static variables first(to memory management). https://msdn.microsoft.com/en-us/library/7977wcck.aspx But, there is #pragma init_seg(compiler) in…
P-P
  • 1,670
  • 5
  • 18
  • 35
15
votes
5 answers

Should I turn on Perl warnings with the command-line switch or pragma?

Is there a difference between the two examples below for beginning a Perl script? If so, when would I use one over the other? example 1: #!/usr/bin/perl use warnings; example 2: #!/usr/bin/perl -w
cowgod
  • 8,626
  • 5
  • 40
  • 57