predefined-macro

__cplusplus < 201402L return true in gcc even when I specified -std=c++14

有些话、适合烂在心里 提交于 2021-02-06 06:36:13
问题 The directive: #ifndef __cplusplus #error C++ is required #elif __cplusplus < 201402L #error C++14 is required #endif The command-line: g++ -Wall -Wextra -std=c++14 -c -o header.o header.hpp My g++ version: g++ (tdm-1) 4.9.2 The error C++14 is required is generated even when I added -std=c++14 , I don't know why. Please tell me how to fix this. 回答1: According to the GCC CPP manual (version 4.9.2 and 5.1.0): __cplusplus This macro is defined when the C++ compiler is in use. You can use _

__cplusplus < 201402L return true in gcc even when I specified -std=c++14

巧了我就是萌 提交于 2021-02-06 06:35:36
问题 The directive: #ifndef __cplusplus #error C++ is required #elif __cplusplus < 201402L #error C++14 is required #endif The command-line: g++ -Wall -Wextra -std=c++14 -c -o header.o header.hpp My g++ version: g++ (tdm-1) 4.9.2 The error C++14 is required is generated even when I added -std=c++14 , I don't know why. Please tell me how to fix this. 回答1: According to the GCC CPP manual (version 4.9.2 and 5.1.0): __cplusplus This macro is defined when the C++ compiler is in use. You can use _

__cplusplus < 201402L return true in gcc even when I specified -std=c++14

亡梦爱人 提交于 2021-02-06 06:30:50
问题 The directive: #ifndef __cplusplus #error C++ is required #elif __cplusplus < 201402L #error C++14 is required #endif The command-line: g++ -Wall -Wextra -std=c++14 -c -o header.o header.hpp My g++ version: g++ (tdm-1) 4.9.2 The error C++14 is required is generated even when I added -std=c++14 , I don't know why. Please tell me how to fix this. 回答1: According to the GCC CPP manual (version 4.9.2 and 5.1.0): __cplusplus This macro is defined when the C++ compiler is in use. You can use _

How can I use #pragma message() so that the message points to the file(lineno)?

左心房为你撑大大i 提交于 2020-02-26 04:42:36
问题 In order to add 'todo' items into my code, I want to put a message in the compiler output. I would like it to look like this: c:/temp/main.cpp(104): TODO - add code to implement this in order to make use of the Visual Studio build output functionality to navigate to the respective line by double-clicking it. But the __LINE__ macro seems to expand to an int , which disallows writing #pragma message( __FILE__ "("__LINE__"): ..." ) Would there be another way? 回答1: Here is one that allows you to

Which version of the Dinkumware STL Lib ships with Visual Studio 2012?

穿精又带淫゛_ 提交于 2020-01-04 01:14:11
问题 In earlier versions of Visual Studio, there was a predefinied macro "_CPPLIB_VER" which reported the version of the Dinkumware STL Library shipped with this version of VS. As of 2012, I am unable to find or use this macro - it is undefinied and I am unable to find any information on this matter online. Is the Dinkumware STL Lib no longer used in VS2012? Was the macro renamed? Windows 7 x64 Microsoft Visual Studio 2012 Professional 回答1: Usually the definition of _CPPLIB_VER can be found in a

How to set predefined macros in Code::Blocks

China☆狼群 提交于 2019-12-23 07:50:02
问题 Is there a way to set some predefined Macros for my local installation of Code::Blocks. To elaborate on that, basically I would like to have certain blocks compiled only at pc and not anyplace I send the code to. One way to achieve this is as follows: #define MYPC #ifdef MYPC //do something #else // do something else #endif I was to achieve the same thing, but I don't want to include the line #define MYPC and woud like to add this somewhere in the IDE. I know how to do this in Visual Studio,

C++ get the month as number at compile time

跟風遠走 提交于 2019-12-20 01:49:06
问题 I have a c++ project that has to print a revision string. The revision string is company wise specified and the protocol includes the build time as yyyy/mm/dd. I use to specify this as macro from the build system, but this is no longer an option because messes up the precompiled headers (in incremental build when the day changes). I am trying to implement this with obtaining the build date from the compiler but __DATE__ and __TIMESTAMP__ give the month in Mmm. Any ideas how I can take the

How can I write a 'clamp' / 'clip' / 'bound' macro for returning a value in a given range?

不打扰是莪最后的温柔 提交于 2019-12-18 04:11:57
问题 I often find myself writing something like int computedValue = ...; return MAX(0, MIN(5, computedValue)); I would like to be able to write this as a single one-line macro. It must be free of side effects, in the same way that the existing system macros MIN and MAX are, and should work for the same data types as MIN and MAX. Can anyone show me how to turn this into a single macro? 回答1: This is without side effects and works for any primitive number: #define MIN(A,B) ({ __typeof__(A) __a = (A);

base file name from __FILE__

巧了我就是萌 提交于 2019-12-12 04:59:22
问题 I need the file name only where the __FILE__ and __FILEW__ macros return the whole path. I defined the following: #define __FILE_NAME_ONLY__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) I am using it as follows: #define MY_TRACE( mask, format, ... ) \ GlobalTrace( mask, L"-[" __FILE_NAME_ONLY__ L":" format , __VA_ARGS__ ) I get the following error: error C2064: term does not evaluate to a function taking 1 arguments and when I try the following macros: #define __WIDE(