pragma

How to put a warning disable pragma inside a macro gcc

旧巷老猫 提交于 2019-12-10 10:38:48
问题 I need to disable a warning that originates inside the macro '__LOG_W' in following code. To do that, I wrapped this macro inside another macro 'LOG_W' and disabled the warning '-Wold-style-cast' with in that. Then in the code I used the LOG_W instead. However I still get the warning and unable to find out why. Any pointers appreciated. #define LOG_W(expr)\ _Pragma("GCC diagnostic push")\ _Pragma("GCC diagnostic ignored \"-Wold-style-cast\"")\ __LOG_W(DEF, UNKNOWN, expr);\ _Pragma("GCC

pragma STDC FENV_ACCESS ON is not supported

て烟熏妆下的殇ゞ 提交于 2019-12-10 09:24:32
问题 I tried to slightly modify the example from the article: #include <iostream> #include <cfenv> #pragma STDC FENV_ACCESS ON int main() { std::feclearexcept(FE_ALL_EXCEPT); //int r = std::feraiseexcept(FE_UNDERFLOW | FE_DIVBYZERO); double x = 1.0; double y = 0.0; double result{}; asm volatile ("fldl %1\n" "fdivl %2\n" : "=%t"(result) : "m"(x), "m"(y) : "memory"); std::cout << result << std::endl; int e = std::fetestexcept(FE_ALL_EXCEPT); if (e & FE_DIVBYZERO) { std::cout << "division by zero\n";

Haskell / GHC: {-# SPECIALIZE #-} Causes 'RULE left-hand side too complicated to desugar' Warning

点点圈 提交于 2019-12-10 04:10:17
问题 I have a body of code that uses a monad to abstract whether the actual implementation runs inside ST or IO. Removing the extra layer of abstraction and just substituting concrete types gives a huge speedup (~4.5x) due to the inlining and missing typeclass function call overhead. I was thinking of getting some of that performance by using a specialize pragma, but I'm getting a rather meaningless warning from the compiler. I can't make a simple reproduction case as the simple example seems to

Is it possible to disable compiler warning C4503?

主宰稳场 提交于 2019-12-10 03:49:21
问题 The following code does NOT suppress ANY C4503 compiler warnings, but it does suppress C4244 warnings. #pragma warning(push) #pragma warning(disable:4503) #pragma warning(disable:4244) #include <map> #include <string> int main(int argc, char *argv[]) { class Field; typedef std::map<std::string, Field * > Screen; typedef std::map<std::string, Screen> WebApp; typedef std::map<std::string, WebApp> WebAppTest; typedef std::map<std::string, WebAppTest> Hello; Hello MyWAT; // The C4503 error is NOT

What is the use of “#pragma section <XYZ>” in C?

浪尽此生 提交于 2019-12-10 02:58:01
问题 What is the use of "#pragma section <XYZ>" in C ? I have come across C code file where the following kind was used:- #define XYZ "ITEM 26.G03" #pragma section <XYZ> where XYZ is: #define XYZ "ITEM 26.G03" I need some explaination on the use of "#pragma section" 回答1: The #pragma directive is an implementation specific directive it is a standard way to provide additional information to the compiler. This directive has the following form: #pragma name If the preprocessor recognizes the specified

openMP conditional pragma “if else”

可紊 提交于 2019-12-10 02:20:10
问题 I have a for loop that can be executed using schedule(static) or schedule(dynamic, 10) depending on a condition. Currently, My code is not DRY (Don't repeat yourself) enough and to accommodate the previous functionality it has the following repetition: boolean isDynamic; //can be true or false if(isDynamic){ #pragma omp parallel for num_threads(thread_count) default(shared) private(...) schedule(dynamic, 10) for(...){ //for code inside } }else{ #pragma omp parallel for num_threads(thread

When to use pragmas on sqlite?

给你一囗甜甜゛ 提交于 2019-12-09 17:27:57
问题 When the pragmas are used? When the database is created for first time or in each connection to database? 回答1: this depends on the pragma being used. from The definitive guide to SQLite, Database Configuration: Many pragmas have both temporary and permanent forms. Temporary forms affect only the current session for the duration of its lifetime. The permanent forms are stored in the database and affect every session. or, in the words of your question: Temporary forms are used in each

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

我只是一个虾纸丫 提交于 2019-12-09 14:09:37
问题 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() __attribute__((deprecated("Warning: deprecated routine"))) #pragma clang diagnostic pop into this: MY_DEPRECATED_BEGIN void Foo() MY_DEPRECATED MY_DEPRECATED_END The MY_DEPRECATED_BEGIN macro is giving me trouble as I have to specify two pragmas in a

How to poison an identifier in VC++?

做~自己de王妃 提交于 2019-12-09 11:37:42
问题 Function poisoning is very useful technique in C++. In general it refers to making a function unusable, e.g. if you want to ban the use of dynamic allocation in a program you could "poison" the malloc function so it can't be used. 'Poisoning' an identifier means that any reference to the identifier after the 'poisoning' is a hard compiler error For example (See live demo here) #include <iostream> #include <cstdlib> #pragma GCC poison malloc int main() { int* p=(int*)malloc(sizeof(int)); //

How do people handle warning C4793: 'some_function' : function compiled as native?

二次信任 提交于 2019-12-09 07:55:31
问题 I'm using the OpenCV library and one of its header files, cxoperations.hpp, generates "warning C4793: 'anonymous namespace'::CV_XADD' : function compiled as native" , if my C++ project is compiled with CLR support. I can prevent the warning by surrounding the OpenCV header include like this: #pragma managed(push,off) #include <cv.h> #pragma managed(pop) But the project that actually uses OpenCV isn't compiled with CLR support, it's a native C++ static library. The project that does have CLR