pragma

Where does the word “pragma” come from?

独自空忆成欢 提交于 2019-11-28 16:47:00
So I know what pragma is, and what it's used for, but what is the meaning of the word itself? I've used it many times in code, but I never really knew what the word actually means or stands for. martin clayton According to a US Government-owned(!) document describing the design of Ada: Rationale for the Design of the Ada® Programming Language : A pragma (from the Greek word meaning action) is used to direct the actions of the compiler in particular ways, but has no effect on the semantics of a program (in general). I like the (last caveat) there... This cross references well with on-line greek

C#: Is pragma warning restore needed?

巧了我就是萌 提交于 2019-11-28 11:52:23
From msdn I get this: #pragma warning disable warning-list #pragma warning restore warning-list In the examples, both disable and restore are used. Is it necessary to restore if I want it disabled for a whole file? Like, if I do not restore, how far does it carry? Are the warnings disabled for everything compiled after that? Or just for the rest of that file? Or is it ignored? If you do not restore the disabling is active for the remainder of the file. Interestingly this behaviour is not defined in the language specification . (see section 9.5.8) However the 9.5.1 section on Conditional

Conditional “pragma omp”

…衆ロ難τιáo~ 提交于 2019-11-28 11:28:58
I am trying different kinds of parallelization using OpenMP. As a result I have several lines of #pragma omp parallel for in my code which I (un-)comment alternating. Is there a way to make these lines conditional with something like the following, not working code? define OMPflag 1 #if OMPFlag pragma omp parallel for for ... An OpenMP parallel construct can have an if clause specified. In Fortran I'd write something like this: !$omp parallel if(n>25) ... I sometimes use this when a problem might be too small to bother parallelising. I guess you could use the same approach to check a debug

Does the program execution always start from main in C?

风格不统一 提交于 2019-11-28 10:36:21
Must program execution start from main, or can the starting address be modified? #include <stdio.h> void fun(); #pragma startup fun int main() { printf("in main"); return 0; } void fun() { printf("in fun"); } This program prints in fun before in main . The '#pragma' command is specified in the ANSI standard to have an arbitrary implementation-defined effect. In the GNU C preprocessor, '#pragma' first attempts to run the game 'rogue'; if that fails, it tries to run the game 'hack'; if that fails, it tries to run GNU Emacs displaying the Tower of Hanoi; if that fails, it reports a fatal error.

Disabling OpenMP pragma statements everywhere in my c++ project

。_饼干妹妹 提交于 2019-11-28 10:08:11
问题 In my c++ project, there are several #pragma omp parallel for private(i) statements. When I try to track down bugs in my code using valgrind, the OpenMP adornments result in "possibly lost" memory leak messages. I would like to totally disable all of the aforementioned #pragma statements so that I can isolate the problem. However, I use omp_get_wtime() in my code, and I do not wish to disable these function calls. So I don't want to totally disable all OpenMP functionality in my project. How

Is it possible to have a “#pragma mark” hierarchy?

给你一囗甜甜゛ 提交于 2019-11-28 09:55:05
I use #pragma mark - Description frequently to organize my methods in Xcode. However, I find that sometimes I need to categories and subcategories for my methods, like this: Public Methods Helper Methods aMethod Other Type of Methods anotherMethod Private Methods Some Type of Method aPrivateMethod Is this possible? Simply only use the - before and after your main section to surround it in lines, exclude the dash for the subsections, and then the method names will show as always. #pragma mark - Public Methods - #pragma mark Helper Methods - (void)aMethod{} #pragma mark Other Type of Methods -

GCC does not honor 'pragma GCC diagnostic' to silence warnings [duplicate]

折月煮酒 提交于 2019-11-28 08:08:32
This question already has an answer here: Suppress -Wunknown-pragmas warning in GCC 1 answer We recently enabled -Wall for a project. Its enabled when GCC is at 4.7 or above (or Clang) because we can use GCC diagnostic to manage the output from the elevated warnings. We want to manage them from the source code, and not via command line arguments. (We don't want to pollute the command line, or ask library users to rediscover what is needed). Under GCC 4.8 and 5.1, we are catching warnings that were disabled in a GCC diagnostic block for -Wunused-variable , -Wunused-value , -Wunused-function and

How to disable #pragma warnings?

醉酒当歌 提交于 2019-11-28 07:08:43
While developing a C++ application, I had to use a 3rd party library which produced a huge amount of warnings related with a harmless #pragma directive being used. ../File.hpp:1: warning: ignoring #pragma ident In file included from ../File2.hpp:47, from ../File3.hpp:57, from File4.h:49, Is it possible to disable this kind of warnings, when using the GNU C++ compiler? I believe you can compile with -Wno-unknown-pragmas to suppress these. In GCC, compile with -Wno-unknown-pragmas In MS Visual Studio 2005 (this question isn't tagged with gcc, so I'm adding this for reference), you can disable

How to disable a specific nvcc compiler warnings

我只是一个虾纸丫 提交于 2019-11-28 06:30:34
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 the source file where we want to disable the warnings, but a compiler flag would also be fine, if one exists to turn off only the warning in question. user2333829 It is actually possible to disable specific warnings on the device with NVCC. It took me ages to figure out how to do it. You need to use the -Xcudafe flag combined with a token listed on

_Pragma preprocessor operator in Visual C++

女生的网名这么多〃 提交于 2019-11-28 03:55:56
问题 Is there something like the ANSI C operator _Pragma in Visual C++? For example, I'm trying to define the following macro: #ifdef _OPENMP #define PRAGMA_IF_OPENMP(x) _Pragma (#x) #else // #ifdef _OPENMP #define PRAGMA_IF_OPENMP(x) #endif // #ifdef _OPENMP So I can circumvent compiler warnings for unknown #pragma omp ... in older GCC compilers. Is there a similar means available in VisualC++? 回答1: Yes, but it's two underscores: __pragma I'm not sure about how the omp pragma works, however, here