pragma

Suppress -Wunknown-pragmas warning in GCC

安稳与你 提交于 2019-11-27 05:53:42
问题 I try to ignore warnings coming from some 3rd party header files like this: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" #pragma GCC diagnostic ignored "-Wreorder" #include <some_3rd_party_header.h> #pragma GCC diagnostic pop This approach seems to work in general, but not for the unknown pragma warnings (I still get them). Why does it work for other warnings but not for this one? Can anyone confirm this behaviour? I'm using g++ (version 4.7.1) with -Wall and

How to disable a specific nvcc compiler warnings

纵饮孤独 提交于 2019-11-27 05:37:19
问题 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. 回答1: It is actually possible to disable specific warnings on the device with NVCC. It took me ages

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

一个人想着一个人 提交于 2019-11-27 03:23:58
问题 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? 回答1: 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

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

时光毁灭记忆、已成空白 提交于 2019-11-27 02:05:42
问题 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

How to disable WAL journal mode

亡梦爱人 提交于 2019-11-27 01:59:41
https://developer.apple.com/library/ios/releasenotes/DataManagement/WhatsNew_CoreData_iOS/ I am having trouble in disabling journal mode. My code is: static NSManagedObjectContext *managedObjectContext(){ static NSManagedObjectContext *context = nil; if (context != nil) { return context; } NSString * const NSSQLitePragmasOption; NSSQLitePragmasOption : @{ @"journal_mode" : @"DELETE" }; @autoreleasepool { context = [[NSManagedObjectContext alloc] init]; NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedObjectModel()]; [context

How to disable #pragma warnings?

不羁岁月 提交于 2019-11-27 01:27:31
问题 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? 回答1: I believe you can compile with -Wno-unknown-pragmas to suppress these. 回答2: In GCC, compile with -Wno-unknown-pragmas In

Why isn't C/C++'s “#pragma once” an ISO standard?

久未见 提交于 2019-11-26 22:57:27
I am currently working on a big project and maintaining all those include guards makes me crazy! Writing it by hand is frustrating waste of time. Although many editors can generate include guards this doesn't help much: Editor generates guard symbol based on a filename. The problem occurs when you have headers with the same filename in different directories. Both of them will get the same include guard. Including directory structure into the guard symbol would require some fancy approach from the editor, since slashes and backslashes in the macro are not the best thing. When I have to rename a

Is there a compiler hint for GCC to force branch prediction to always go a certain way?

天大地大妈咪最大 提交于 2019-11-26 21:25:45
For the Intel architectures, is there a way to instruct the GCC compiler to generate code that always forces branch prediction a particular way in my code? Does the Intel hardware even support this? What about other compilers or hardwares? I would use this in C++ code where I know the case I wish to run fast and do not care about the slow down when the other branch needs to be taken even when it has recently taken that branch. for (;;) { if (normal) { // How to tell compiler to always branch predict true value? doSomethingNormal(); } else { exceptionalCase(); } } As a follow on question for

Is using #pragma warning push/pop the right way to temporarily alter warning level?

ⅰ亾dé卋堺 提交于 2019-11-26 19:42:15
Once in a while it's difficult to write C++ code that wouldn't emit warnings at all. Having warnings enabled is however a good idea. So it is often necessary to disable warnings around some specific construct and have them enables in all other pieces of code. I've seen two ways of doing that so far. The first one is to use #pragma warning( push ) and #pragma warning( pop ) : #pragma warning( push ) #pragma warning( disable: ThatWarning ) //code with ThatWarning here #pragma warning( pop ) The second is to use #pragma warning( default ) : #pragma warning( disable: ThatWarning ) //code with

Best workaround for compiler error C2158: make_public does not support native template types

﹥>﹥吖頭↗ 提交于 2019-11-26 18:34:24
问题 I have two c++/cli dlls (i.e. compiled with /clr) where A.dll references B.dll. In assembly B, I have a method, GetMgdClassB, I'd like to call from assembly A. Here is the code in assembly B (B.cpp): namespace B { public class NativeClassB { public: NativeClassB(); // ... }; public ref class MgdClassB { public: static MgdClassB ^ GetMgdClassB(const std::vector<NativeClassB *> & vecNativeBs) { // ... vecNativeBs; return gcnew MgdClassB(); } }; } Notice that the method GetMgdClassB takes a std: