pragma

Conditional “pragma omp”

微笑、不失礼 提交于 2019-12-17 19:52:15
问题 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 ... 回答1: 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

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

你。 提交于 2019-12-17 18:18:14
问题 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; uint8_t bit_depth; uint8_t color_type; uint8_t compression; uint8_t filter; uint8_t interlace; }; #pragma pack() STATIC_ASSERT(expected_13bytes, sizeof(struct ChunkStruct) == 13); I have tried unsuccesfully using #pragma pack(push, 1) /* struct ChunkStruct { ...

How to silence a warning in swift

大憨熊 提交于 2019-12-17 15:08:34
问题 I have a piece of code which is generating lots of warnings (deprecated API) Using clang* I could do #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" ... #pragma clang diagnostic pop However this does not work in swift. How to do it in swift ? Note: I don't want to disable the warning globally, nor even file wide, but just disable a specific warning in a specific part of my source code. Edit: I looks like my note was not clear enough: I do NOT want

Tell gcc to specifically unroll a loop

天大地大妈咪最大 提交于 2019-12-17 04:27:52
问题 How can I tell GCC to unroll a particular loop? I have used the CUDA SDK where loops can be unrolled manually using #pragma unroll . Is there a similar feature for gcc? I googled a bit but could not find anything. 回答1: GCC gives you a few different ways of handling this: Use #pragma directives , like #pragma GCC optimize ("string"...) , as seen in the GCC docs. Note that the pragma makes the optimizations global for the remaining functions. If you used #pragma push_options and pop_options

Disable single warning error

耗尽温柔 提交于 2019-12-17 02:35:15
问题 Is there a way to disable just a single warning line in a cpp file with visual studio? For example, if I catch an exception and don't handle it, I get error 4101 (unreferenced local variable). Is there a way to ignore this just in that function, but otherwise report it in the compilation unit? At the moment, I put #pragma warning (disable : 4101) at the top of the file, but that obviously just turns it off for the whole unit. 回答1: #pragma warning( push ) #pragma warning( disable : 4101) //

How to disable a specific IBM XL C++ compiler warning?

倖福魔咒の 提交于 2019-12-13 17:53:22
问题 Given tmp.cpp: #include <stdio.h> #pragma report(disable, CCN8826) int main(int argc, const char *argv[]) { const char * hi = "hi\n"; printf(hi); return 0; } Despite I use #pragma report that is supposed to suppress the warning, I still get: bash-3.1$ xlC -qformat=all tmp.cpp "tmp.cpp", line 8.12: 1540-2826 (W) The format string is not a string literal and format arguments are not given. How do I get rid of that warning? The error message numbers are here and the #pragma report description is

Use of #pragma pack on a class

放肆的年华 提交于 2019-12-13 14:22:58
问题 Can we use #pragma pack() before a class? What is the significance of pragma here? I know it is used for giving information to compiler regarding implementation, but what if we use it with a class? 回答1: It has the exact same effect on a class as it does on a struct, affecting the alignment of data members. Actually using it on a class is very unusual and almost always a mistake. The layout of a C++ class object is heavily implementation defined. A C++ compiler usually makes an effort to

About collapsing code block in Visual Studio using #pragma region

本小妞迷上赌 提交于 2019-12-13 12:33:52
问题 In VisualStudio, when you write a function it can collapse to outlines, everyone knows it. Also you can use #pragma region and #pragma endregion to manually specify a code region so that it can collapse. However I found a problem that, if any collapsed code blocks are within the #pragma region , they cannot collapse anymore. Is there any way to solve it? 回答1: There are several other also better and flexible ways than #pragma region you can do to collapse code in VS: Method 1: Use {...}

Finding the line number of a function in Haskell

天涯浪子 提交于 2019-12-13 12:09:43
问题 I am trying to create a Haskell program which draws some simple 2d shapes to screen, but when you hover over each shape, it prints the line of source code where the shape was created. In order to do this I would like to be able to create shapes with parameters for their dimensions and a final parameter which indicates the line number. Something like this: rect1 = Shape(Rectangle 2 2 lineNumber) This would create a rectangle of width 2 pixels, height 2 pixels, and use a function lineNumber to

Is it Possible MARK: (#pragma mark) in Localizable.string file

ぃ、小莉子 提交于 2019-12-13 00:24:19
问题 Pragma mark not working in Localizable.strings file. If I add second MARK: (#pragma mark) in Localizable.strings , xcode rise compile time error error: read failed: The data couldn’t be read because it isn’t in the correct format. See below Image, When I was added the first pragma mark // MARK: MENU ITEMS , it didn't show any error. But when I add the second mark // MARK: EMAIL SETTINGS it shows the above error. My intention is simple, Localizable.strings should be in organized ordered like