placement new and delete

The correct method is: buf->~Buffer(); ::operator delete(mem); You can only delete with the delete operator what you received from the new operator. If you directly call the operator new function, you must also directly call the operator delete function, and must manually call the destructor as well.

Problem calling std::max

You are probably including windows.h somewhere, which defines macros named max and min. You can #define NOMINMAX before including windows.h to prevent it from defining those macros, or you can prevent macro invocation by using an extra set of parentheses: column = (std::max)(1u, column + count);

How to suppress warnings in external headers in Visual C++

Use this method around (a) header(s) that you cannot or don’t want to change, but which you need to include. You can selectively, and temporarily disable all warnings like this: #pragma warning(push, 0) // Some include(s) with unfixable warnings #pragma warning(pop) Instead of 0 you can optionally pass in the warning number to disable, so … Read more

error LNK2038: mismatch detected for ‘_MSC_VER’: value ‘1600’ doesn’t match value ‘1700’ in CppFile1.obj

TL;DR; Recompile all your old static-linked .lib files with current-compiler (VS2012, in OP’s case). You are trying to link objects compiled by different versions of the compiler. That’s not supported in modern versions of VS, at least not if you are using the C++ standard library. Different versions of the standard library are binary incompatible … Read more

Is it possible to force a function not to be inlined?

In Visual Studio 2010, __declspec(noinline) tells the compiler to never inline a particular member function, for instance: class X { __declspec(noinline) int member_func() { return 0; } }; edit: Additionally, when compiling with /clr, functions with security attributes never get inlined (again, this is specific to VS 2010). I don’t think it will prove at … Read more

GCC worth using on Windows to replace MSVC?

MSVC has the huge advantage of coming with an IDE that has no equals under Windows, including debugger support. The probably best alternative for MinGW would be Code::Blocks, but there are worlds in between, especially regarding code completion and the debugger. Also, MSVC lets you use some proprietary Microsoft stuff (MFC, ATL, and possibly others) … Read more

Why aren’t static const floats allowed? [duplicate]

To answer the actual question you asked: “because the standard says so”. Only variables of static, constant, integral types (including enumerations) may be initialized inside of a class declaration. If a compiler supports in-line initialization of floats, it is an extension. As others pointed out, the way to deal with static, constant, non-integral variables is … Read more