visual-c++

C standard library corner case

北战南征 提交于 2021-01-28 08:35:16
问题 Is the following program a valid C program? #include <stdio.h> int main() { fwrite("x", 1, 1, stderr); fflush(stderr); fgetc(stderr); fwrite("y", 1, 1, stderr); return 0; } Notice that I try to read from stderr. When I compile it in Visual C++ 2008, and run it, I get the following output: xy which makes sense. However, when I redirect stderr to a file ( test.exe 2> foo.txt ), I get a "Debug Assertion Failed" window with the message: "Inconsistent Stream Count. Flush between consecutive read

Segmentation fault in std::vector::erase() in Visual C++

╄→гoц情女王★ 提交于 2021-01-28 08:28:34
问题 I am having a segmentation fault in the erase function of std::vector that is driving me crazy. Am having the following code: std::map<uint32_t, std::vector<boost::uuids::uuid> >::iterator it = theAs.find(lSomeUint32); if (it != theAs.end()) { std::vector<boost::uuids::uuid>& lIds = it->second; // vector contains one entry std::vector<boost::uuids::uuid>::iterator it2 = lIds.begin(); while (it2 != lIds.end()) { if (*it2 == lSomeUuid) { lIds.erase(it2); break; } ++it2; } } In lIds.erase(it2),

xsd.exe does not seem to work for C++ with newer versions of Visual Studio

江枫思渺然 提交于 2021-01-28 08:08:29
问题 I am trying to use the xsd.exe tool to generate C++ classes from XML schema files. According to this post I should simply be able to use the tool from a Visual Studio developer command prompt, but it doesn't seem to work for C++ in newer versions of Visual Studio (2017 or 2019) When I try to execute the command I get the error: Error: The CodeDom provider type "Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" could not be

Is there any way to complie a microsoft style inline-assembly code on a linux platform?

試著忘記壹切 提交于 2021-01-28 08:04:57
问题 As mentioned in title, i'm wondering that is there any way to compile a microsoft style inline-assembly code (as showed below) in a linux OS (e.g. ubuntu). _asm{ mov edi, A; .... EMMS; } The sample code is part of a inline-assembly code which can be compiled successfully on win10 with cl.exe compiler. Is there any way to compile it on linux? Do i have to rewrite it in GNU c/c++ style (i.e. __asm__{;;;})? 回答1: First of all, you should usually replace inline asm (with intrinsics or pure C)

isupper and islower for wstring

老子叫甜甜 提交于 2021-01-28 07:07:53
问题 I have a std::wstring and I want to find which character are upper case and which ones are lowercase. the std::isupper and islower seems to work on ASCII characters only but I want to be able to find out all kinds of uppercase and lowercase characters e.g. á is an "Latin small letter a with acute" and Á is an "Latin capital letter A with acute" similarly ä and Ä are lower and upper case german letters. Is there any function (mfc, boost or in any other library) which I can use to find out if a

How to create EGLSurface using C++/WinRT and ANGLE?

坚强是说给别人听的谎言 提交于 2021-01-28 06:44:34
问题 I'm using the Microsoft branch of the ANGLE project to have access to OpenGL in a Universal Windows application. Also I use the C++/WinRT binding to code as much in standard C++ as possible. I started from one of the examples in the ANGLE project and tried to convert the C++/CX code to C++/WinRT code, but I fail to find a solution for the part where I create an EGL Surface: mEGLSurface = eglCreateWindowSurface(mEGLDisplay, config, /*WHERE IS MY HWND?*/, NULL); In the C++/CX they use the

Why do I still get “unresolved external symbol” error after adding the reference to the test project?

家住魔仙堡 提交于 2021-01-28 04:41:49
问题 I created a C++ project in Visual Studio 2019. I added two files to it: MyClass.hpp and MyClass.cpp . Then I created a test project and added the original project as a reference. If I doubleclick on the reference in the test project, I can see MyClass . But if I try to run the tests, I get this error: MyTest.obj : error LNK2019: unresolved external symbol "public: struct MyRef __thiscall MyClass::SetData(struct Data)" (?SetData@MyClass@@QAE?AUMyRef@@UData@@@Z) referenced in function "private:

Can you use a.b notation in a #define macro name?

送分小仙女□ 提交于 2021-01-28 04:28:41
问题 I want to declare a define, using Visual Studio 2008 or 2010, like that: #define a.b c.d and I get following error: error C2008: '.' : unexpected in macro definition I see that I am allowed to create a define like this: #define a c.d Is the a.b notation supposed to be allowed in the macro name? 回答1: Macros has same set of rules for naming, as do identifiers. In fact, macro-names are identifiers. So, They cannot contain dot. They can consist of only alphabet, digits, and underscore. Nothing

Tool to convert xsd to c++ code

我的梦境 提交于 2021-01-28 04:21:44
问题 Is there any tool to convert xsd to c++ code. The generated code can be used for serialization and parsing the xml. It should also be run as a independent. I saw some opensource tools like CodeSynthesis but it has covered by GPL license. I am looking for a tool which will generate code that could run independently. 回答1: xsd.exe generates code for C++\CLI too. It is not added in \languages in the documentation. But when executing xsd.exe in VS CommandPrompt, in the \languages section you could

CreateNamedPipe ERROR_INVALID_NAME

对着背影说爱祢 提交于 2021-01-28 03:10:23
问题 Code snippet: void RunThread(void* unused_args) { PSECURITY_DESCRIPTOR sdsc; ULONG size; ConvertStringSecurityDescriptorToSecurityDescriptor("S:(ML;;NW;;;LW)", SDDL_REVISION_1, &sdsc, &size); SECURITY_ATTRIBUTES sa; sa.nLength = sizeof(sa); sa.bInheritHandle = false; sa.lpSecurityDescriptor = sdsc; HANDLE pipe = CreateNamedPipe("\\.\pipe\mmaivpc_test_pipe", PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE, 255, 1024, 1024, 0, &sa); DWORD error = GetLastError(); } If you haven't figured it out from the