visual-c++-2008

VC9 and VC8 lib compatibility

(The original question was asked there : http://www.ogre3d.org/phpBB2/viewtopic.php?t=44832 ) Someone asked : "While I would like to build everything in vs2008 (VC9), the PhysX SDK is built with vs2005 (VC8). Would this cause any problems, using all vc9 compiled libs and used in combination with this vc8 lib?" I answered that the day ...

How do I increase the allowed decorated name length in VC9 (MSVC 2008)?

I have a rather large and complex set of programs to port from VC8 to VC9. One of the modules has a number of layered typedefs, which cause the compiler to generate a C4503 warning (decorated name truncated). The generated LIB file will not properly link to other modules in the project. VC8 had no trouble with this, leading me to conclud...

ActiveX plugin causes ASSERT to fail on application exit in VS2008

My MFC application using the "ESRI MapObjects LT2" ActiveX plugin throws an ASSERT at me when closing it. The error occurs in cmdtarg.cpp: CCmdTarget::~CCmdTarget() { #ifndef _AFX_NO_OLE_SUPPORT if (m_xDispatch.m_vtbl != 0) ((COleDispatchImpl*)&m_xDispatch)->Disconnect(); ASSERT(m_dwRef <= 1); //<--- Fails because m_dwRef i...

What are the porting issues going from VC8 (VS2005) to VC9 (VS2008)?

I have inherited a very large and complex project (actually, a 'solution' consisting of 119 'projects', most of which are DLLs) that was built and tested under VC8 (VS2005), and I have the task of porting it to VC9 (VS2008). The porting process I used was: Copy the VC8 .sln file and rename it to a VC9 .sln file. Copy all of the VC8...

Using C++ DLLs with different compiler versions

This question is related to "How to make consistent dll binaries across VS versions ?" We have applications and DLLs built with VC6 and a new application built with VC9. The VC9-app has to use DLLs compiled with VC6, most of which are written in C and one in C++. The C++ lib is problematic due to name decoration/mangling issues. Compil...

How to use resources in VC++?

I am using VC 9 and I want to support Russian language for my application. I even created Russian resource strings. But my system has Russian Language setting. If it is not there every character displays junk (its code page is 1251). I also made DLL from Russian resource file. If I run that DLL in application from installed location, it ...

error c2664 upon using basic_string<wchar_t> abc("hello") in vc++ 9.0

Hi upon compiling this code in Visual studio 2008 i get the following error #include<iostream> #include<string> using namespace std; void main() { basic_string<wchar_t> abc("hello world"); cout<<abc; return; } error C2664: 'std::basic_string<_Elem,_Traits,_Ax>::basic_string(std::basic_string<_Elem,_Traits,_Ax>::_Has_deb...

View Compiler Mangled Names in C++

How do I view the compiler-generated mangled names for overloaded functions in C++? I'm using VC9 but answers for other compilers are welcome too. Edit: I find all the answers useful here. Accepting the one I liked best. ...

Return value optimization in VC2008

Is there other technique like RVO (return value optimization) or NRVO (named return value optimization) that can be use with VC2008? ...

"Cannot convert parameter" using boost::variant iterator

I want to create a function that can take different types of iterators which store the same type of object: The first is a std::map containing shared_ptr<Foo> (typedef-ed as FooMap) and the other is a std::list which also contains shared_ptr<Foo> (FooList). I really like the solution MSalters suggested for a similar question and tried t...

stringstream bug in VC9? "Cannot access private member"

std::string str; std::stringstream strm(str); I get this error: Error 11 error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' c:\program files\microsoft visual studio 9.0\vc\include\sstream 517 If I use istringstream, same happens...

Migrating from Visual C++ 6 to Visual C++ 2008 express

Hi, I'm tring to migrate my code from VCpp 6 to VCpp 2008 express but when I build the solution I receive this error message: icl: warning: problem with Microsoft compilation of 'c:\Desenvolvimento\DFF\Base\\version.cpp' 1>C:\Arquivos de programas\Microsoft Visual Studio 9.0\VC\include\string.h(69): error: expected a ";" 1> __DEFINE...

Bad pointer or link issue when creating wstring from vc6 dll

I got a DLL generated on VC6 and using wstring, and I'm trying to use it in a VC9 project. In this DLL there is a higher level class manipulating wstring, called UtfString. I got everything imported correctly in my project, but when I call: std::wstring test; UtfString uTest(test); it won't link, even if the function prototype is in...

How to detect "Use MFC" in preprocessor

For a static Win32 library, how can I detect that any of the "Use MFC" options is set? i.e. #ifdef ---BuildingForMFC--- .... #else ... #endif ...

Different destructor behavior between vc9 and gcc

The following code gives a different number of destructors when compiled on GCC and vc9. AFAIK when run on vc9 i get 5 destructors showing, which I understand. The + overloaded operator is called, and two object are created, when returned a temporary object is created. This makes destruction of 3 objects possible. When the overloaded = o...

this compiles without a warning in VC9 at warning level 4. Why would one NOT consider this a compiler defect?

I saw some posted code with an out of range error on SO that made me wonder. I would expect a compiler to generate a warning (at the highest level at least) for this code #pragma warning(push,4) int main(){ int x[2]; x[2]=0; return 0; } #pragma warning(pop) but it does not. The EDG compiler nicely says: "sourceFil...

AfxLoadLibrary change from vc6 to vc9 wrt paths

I'm working on migrating from vc6 to vc9. Things are generally working well but I ran into a nasty snag today. We have a whole pile of optional Dlls that were written as extension dlls. They get put into a sub-folder: mainapp/plugins/plugintype/*.dll AfxLoadLibrary used to work nicely but it no longer does. A little experimenting reve...

run time detection of processor type - atomic operations

I am implementing some speed critical multithreaded code. I can avoid having some critical sections if I know for certain that some basic write operations are atomic. I just read an academic paper in which I saw the following: "Writes of the basic types size t, int, float and pointer must be atomic. Writes by one thread must be seen by ...

Can I use a C style library built with VC6 directly in VC9 project?

We use an internal library(developed by some other team) built with VC6 compiler. This library mainly contains C Style APIs. We have a plan to migrate to Visual Studio 9 compiler. Should I request for the library to be built with VC9 compiler? A more generic question, On which points ( may be name mangling, optimization etc) a DLL buil...

How to determine which C/C++ objects use most memory

Hi! I have a mixed mode application (managed and native) which has a high memory footprint. I already have found out that most of the memory is allocated by native code. I am not talking about a memory leak, but about a high memory consumption that occurs very early after the program starts and then is relatively stable. Are you aware ...