visual-c++

Why does this code using __LINE__ compile under MSVC in Release mode, but not in Debug mode?

独自空忆成欢 提交于 2020-07-20 06:47:27
问题 Consider this program: #include <iostream> template<bool Debug = false, int Line = __LINE__> constexpr int adds(const int& a, const int& b) { if (Debug) std::cout << __FUNCTION__ << " called on line " << Line << '\n'; return (a + b); } int main() { std::cout << adds(3, 7) << '\n'; std::cout << adds<true, __LINE__> (5, 9) << '\n'; return 0; } When I try to compile and build this in Debug mode Visual Studio 2017 is generating these compiler errors: 1>------ Build started: Project: Simulator,

QDateTime::fromstring( __DATE__, “MMM d yyyy”) returns invalid

孤者浪人 提交于 2020-07-18 06:17:17
问题 Parsing the MSVC++ predefined __DATE__ (maybe in conjunction with __TIME__ ) macro with QDateTime::fromstring() returns nothing (= an invalid QDateTime object). Why? 回答1: From http://msdn.microsoft.com/en-us/library/b0084kay%28v=vs.80%29.aspx: DATE The compilation date of the current source file. The date is a string literal of the form Mmm dd yyyy. The month name Mmm is the same as for dates generated by the library function asctime declared in TIME.H. The dd part seems to be filled with a

Reading UTF-8 characters from console

十年热恋 提交于 2020-07-18 05:05:48
问题 I'm trying to read UTF-8 encoded polish characters from console for my c++ application. I'm sure that console uses this code page (checked in properties). What I have already tried: Using cin - instead of "zażółć" I read "za\0\0\0\0" Using wcin - instead of "zażółć" - same result as with cin Using scanf - instead of 'zażółć\0' I read 'za\0\0\0\0\0' Using wscanf - same result as with scanf Using getchar to read characters one by one - same result as with scanf On the beginning of the main

How do I include RealSense2/OpenCV source into compilation with CMake?

99封情书 提交于 2020-07-10 08:37:06
问题 SHORT VERSION I want to bundle the (uncompiled) source files for OpenCV and librealsense2 with CMake so I can cross compile it on RPi (or at all), but I am new to CMake and don't know how. add_executable (CMakeRealSense "CMakeRealSense.cpp" "CMakeRealSense.h") include_directories(opencv libs/opencv-master/include) include_directories(realsense2 libs/librealsense-master/include) This gives a bunch of errors related to RS files itself (X not declared on scope). LONG VERSION I am currently

Visual studio platform toolset vs Windows SDK

淺唱寂寞╮ 提交于 2020-07-09 13:19:31
问题 Why does Microsoft visual studio has different configuration properties for settings 'Windows SDK' and 'platform toolset' in same project? I have the understanding that every windows SDK provides new/different version of platform toolset. So how does it make sense to specify platform toolset of say Windows 10 SDK and at the same time setting the SDK option to say Windows 8.1 SDK in the same project? Very confusing. 回答1: Accoding to the Doc For the Windows target platform, Windows SDK Version

Do I still need to install Microsoft VC++ 2015 runtime redistributable if I already have Microsoft VC++ 2017 runtime installed?

我的梦境 提交于 2020-07-09 11:32:22
问题 From what I read about these posting and elsewhere, regarding the issue of why I cannot install Microsoft VC++ 2015 runtime redistributable if I already have Microsoft VC++ 2017 runtime installed. The reason for this "cannot install" is because once you have Microsoft VC++ 2017 installed, there is no need to install 2015 version,as 2017 subsume 2015. Am I right? Secondly, and more crucially, from now onwards if I have a higher version of Microsoft VC++ installed, I can safely skip the lower

Do I still need to install Microsoft VC++ 2015 runtime redistributable if I already have Microsoft VC++ 2017 runtime installed?

偶尔善良 提交于 2020-07-09 11:31:05
问题 From what I read about these posting and elsewhere, regarding the issue of why I cannot install Microsoft VC++ 2015 runtime redistributable if I already have Microsoft VC++ 2017 runtime installed. The reason for this "cannot install" is because once you have Microsoft VC++ 2017 installed, there is no need to install 2015 version,as 2017 subsume 2015. Am I right? Secondly, and more crucially, from now onwards if I have a higher version of Microsoft VC++ installed, I can safely skip the lower

Chained ostream internal behavior and their results on MSVC (versus Clang)

久未见 提交于 2020-07-09 05:18:16
问题 An issue of streams, internal string, and operation ordering with MSVC versus GCC / Clang Hello everyone, I just recently began to work more seriously with MSVC for a cross-platform project of mine, and while testing outputs via chained STD stream ( ie. a succession of obj.foo() << endl << obj.bar() << endl << [..etc] ) I came across a behavior when using internally updated string neither did I expected nor had encountered on Linux with GCC or Clang . Compiler versions were GCC 7.5, Clang 11

Chained ostream internal behavior and their results on MSVC (versus Clang)

我怕爱的太早我们不能终老 提交于 2020-07-09 05:16:41
问题 An issue of streams, internal string, and operation ordering with MSVC versus GCC / Clang Hello everyone, I just recently began to work more seriously with MSVC for a cross-platform project of mine, and while testing outputs via chained STD stream ( ie. a succession of obj.foo() << endl << obj.bar() << endl << [..etc] ) I came across a behavior when using internally updated string neither did I expected nor had encountered on Linux with GCC or Clang . Compiler versions were GCC 7.5, Clang 11

Imitate Visual C++ with MinGW or other C++ compilers (for Python packages based on Visual C++)

僤鯓⒐⒋嵵緔 提交于 2020-07-08 00:47:55
问题 Is there a way to use MinGW as a substitute of MS Visual C++? A lot of Python packages need VS C++ to be installed: 4.5 GB of disk space! MinGW takes only 450 MB and reaches the same aim to compile C/C++. I am using Visual Studio Code, and I try to avoid the Microsoft Visual C++ installation that is proposed here under 3) --> You can also install just the C++ Build Tools : https://code.visualstudio.com/docs/cpp/config-msvc/#_prerequisites Perhaps there is just a trick needed to imitate MS