visual-c++-2008

Static const variable is not constant in child class

久未见 提交于 2021-02-10 09:34:39
问题 I am using Visual Studio 2008 and have two classes Parent and Child. Parent declares some static const variables in the header, which are then defined in the cpp file. When I try to use the defines as cases in a switch statement in a child class I get the error: C2051: case expression not constant . So I've done some testing and the behavior I'm seeing is somewhat inconsistent. // Parent.h class Parent { public: Parent(); ~Parent(void) { } static const unsigned long A = 1; static const

Static const variable is not constant in child class

早过忘川 提交于 2021-02-10 09:34:16
问题 I am using Visual Studio 2008 and have two classes Parent and Child. Parent declares some static const variables in the header, which are then defined in the cpp file. When I try to use the defines as cases in a switch statement in a child class I get the error: C2051: case expression not constant . So I've done some testing and the behavior I'm seeing is somewhat inconsistent. // Parent.h class Parent { public: Parent(); ~Parent(void) { } static const unsigned long A = 1; static const

dllimport /dllexport and static libraries compilation under visual c++

不羁岁月 提交于 2021-02-08 19:55:35
问题 I desperatly need your help. Im trying to compile statically the poppler library (specially for qt4) on windows with the visual c++ 2008 compiler. To achieve this task I needed to compile a bunch of other libraries as dependencies for poppler statically too. When I finally generate the static version of poppler I got a linking error when building my app: error LNK2019: unresolved external symbol "__declspec(dllimport)... I already added the new include path and linked the poppler-qt4.lib but

Can I control version number assigned to interop assembly?

浪子不回头ぞ 提交于 2020-01-13 03:53:26
问题 I have a C# program that uses a native C++ COM object. Visual Studio generates an interop assembly with wrappers for the types in the COM object. Each time I recompile the C# program interop assembly has version 1.0.0.0. This is bad for the installer - sometimes we extend the COM object interfaces (add new methods at the end of some interface) so the interop assembly has to be changed. when the installer tries to update an existing installation it thinks that the interop assembly hasn't

Error operator new[] : function does not take 1 arguments

佐手、 提交于 2020-01-03 20:03:11
问题 I have code that overloads operator new . The code below works fine under Linux (gcc4x) but not Windows (Visual C++ 2008 Express Edition) The code under Visual Studio 2008 Express Edition reports error C2660: operator new[] : function does not take 1 arguments class dummy{}; void* operator new[] (size_t size, dummy gcp) { return ::operator new[](size); //error } int main() { dummy dummyobj; dummy* ptr = new (dummyobj) dummy[5]; return 0; } 回答1: You might need to #include <new> . 来源: https:/

Error operator new[] : function does not take 1 arguments

隐身守侯 提交于 2020-01-03 20:01:18
问题 I have code that overloads operator new . The code below works fine under Linux (gcc4x) but not Windows (Visual C++ 2008 Express Edition) The code under Visual Studio 2008 Express Edition reports error C2660: operator new[] : function does not take 1 arguments class dummy{}; void* operator new[] (size_t size, dummy gcp) { return ::operator new[](size); //error } int main() { dummy dummyobj; dummy* ptr = new (dummyobj) dummy[5]; return 0; } 回答1: You might need to #include <new> . 来源: https:/

How to recursively dereference pointer (C++03)?

…衆ロ難τιáo~ 提交于 2020-01-01 02:34:25
问题 I'm trying to recursively dereference a pointer in C++. If an object is passed that is not a pointer (this includes smart pointers), I just want to return the object itself, by reference if possible. I have this code: template<typename T> static T &dereference(T &v) { return v; } template<typename T> static const T &dereference(const T &v) { return v; } template<typename T> static T &dereference(T *v) { return dereference(*v); } My code seems to work fine in most cases, but it breaks when

Migrated application crashes, if DEP is active

寵の児 提交于 2019-12-25 00:50:07
问题 I've ported our MFC application from vc6 to vc9 (VS2008). Everything's fine, but if DEP is active, program crashes (s. stacktrace below). I've already tried to play around with NX-Flag, but nothing changes. I also tried to build the application with Parasoft Insure++, but no memory corruptions or any other issues are shown. Thanks in advance for any advice. The environment is as described below: DEP option is NoExecute=OptOut, the program is in the exclude list (if not, it doesn't crash, but

When boost library “interprocess” defines a named_mutex do those named_mutexes work properly between different processes, or only with threads?

橙三吉。 提交于 2019-12-24 05:32:13
问题 I think I must be assuming something from the name boost::interprocess that is not true. The documents repeat that named_mutex is global here. I am unable to make it work though. Two copies of the same executable should be run at the same time, and I expect that a named mutex in a library named boost::interprocess might actually BLOCK sometimes. It doesn't. It also doesn't prevent data file corruption in the code below. Here's some code from the boost docs: #include <boost/interprocess/sync

Overriding memory allocator in MSVC++

南楼画角 提交于 2019-12-23 14:59:36
问题 While Microsoft standard runtime provides debugging version of allocation functions, it does not really work, because you are not supposed to use naked new in C++ code, so the instrumentation points to standard library, or nowhere because standard library can't be instrumented anyway. Now I have code that can produce (and record) backtraces of allocations and I also used DUMA. However attempts at replacing the allocation functions broke when we used streams, because streambuf calls to some