visual-c++-2008

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

こ雲淡風輕ζ 提交于 2019-12-05 15:55:39
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: "sourceFile.cpp", line 3: warning: subscript out of range x[2]=0; ^ Actually EDG says bit more more(all of which are expected) "sourceFile.cpp", line 1: warning: unrecognized #pragma #pragma warning(push,4) ^ "sourceFile.cpp", line 4: warning: subscript out of range x[2]=0; ^ "sourceFile.cpp",

ATL Based Linker Errors

帅比萌擦擦* 提交于 2019-12-05 11:01:49
I got a linking problem with atls.lib lately. I updated my linker's additional dependencies lines with: comctl32.lib C:\WinDDK\7600.16385.1\lib\ATL\i386\atls.lib C:\WinDDK\7600.16385.1\lib\ATL\i386\atl.lib C:\WinDDK\7600.16385.1\lib\ATL\i386\atlsd.lib However, now, I started getting these errors. What can cause these problems? Thank you very much. ------ Build started: Project: hede, Configuration: Debug Win32 ------ Linking... atlsd.lib(externs.obj) : error LNK2005: "char const * const g_pszUpdateEventName" (?g_pszUpdateEventName@@3PBDB) already defined in atls.lib(externs.obj) atlsd.lib

Warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)

余生长醉 提交于 2019-12-04 22:16:20
I have this problem in my code: bool CBase::isNumber() { return (id & MID_NUMBER); } bool CBase::isVar() { return (id & MID_VARIABLE); } bool CBase::isSymbol() { return (id & MID_SYMBOL); } FYI: Casts won't hide the warning by design . Something like return (id & MID_NUMBER) != 0; should clearly state "I want to check whether this value is zero or not" and let the compiler be happy Use the !! idiom eg bool CBase::isNumber() { return !!(id & MID_NUMBER); } Where's the declaration of id and MID_NUMBER? Are you sure they are not windef-style BOOLs rather than (lowercase) bool's? BOOL's have been

VC9 and VC8 lib compatibility

耗尽温柔 提交于 2019-12-04 14:49:02
(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 before i tried to use a .lib file (and a .dll) generated with VC8 and include it in a vc9 compiled exe, the compiler couldn't open the .lib file. Now, other answered they did this with no problems.... I can't find the information about lib compatibility between

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

折月煮酒 提交于 2019-12-03 05:35: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 given function pointers , because dereferencing a function pointer results in the same exact type of

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

浪子不回头ぞ 提交于 2019-12-02 07:45:21
问题 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 conclude that either the decoration process has changed to generate even longer names, or the internal limit for the length of a decorated name has decreased. What's

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

◇◆丶佛笑我妖孽 提交于 2019-12-02 06:28:27
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 conclude that either the decoration process has changed to generate even longer names, or the internal limit for the length of a decorated name has decreased. What's the best way to get over this? For legacy code reasons, the MSDN suggestion of replacing typedefs with

Why do I get these warnings in Visual C++ 2008 when building a struct?

自古美人都是妖i 提交于 2019-12-01 17:00:19
问题 I have this code typedef struct { const char* fooString; const bool fooBool; }fooStruct; And this initializer: static const fooStruct foo[] = { {"file1", true}, {"file2", false}, .... }; With this code I have 3 warnings in VS2008: error C2220: warning treated as error - no 'object' file generated warning C4510: '<unnamed-tag>' : default constructor could not be generated warning C4512: '<unnamed-tag>' : assignment operator could not be generated warning C4610: struct '<unnamed-tag>' can never

How to call VB.NET DLL from C++ (Call the functions also - not DLL file only)

橙三吉。 提交于 2019-12-01 01:01:26
I want to ask question about how to call VB.NET DLL from C++ program I have tried many times to call VB.NET DLL file from C++ and it is working fine but the problem is I can't call the function of VB.NET DLL file ( I can only load the VB.NET DLL file) in VB.NET DLL I have the following code: Public Function example_function1(ByVal i As Integer) As Integer Return 3 End Function Public Function example_function2(ByVal i As Integer) As Integer Return 3 End Function ============================ My C++ Code is: typedef int (__stdcall *ptf_test_func_1_type)(int); typedef int (__stdcall *ptf_test

Compiling a php extension with Visual Studio 2008, MODULE ID don't match with php

跟風遠走 提交于 2019-11-30 23:46:31
After compiling my own php extension using VC9 (2008) and VC10 (2010) using the next steps: http://blog.slickedit.com/2007/09/creating-a-php-5-extension-with-visual-c-2005/ I get the next error when initializing php: PHP Warning: PHP Startup: FirstPHPExt Module: Unable to initialize module Module compiled with build ID=API20090626,TS PHP compiled with build ID=API20090626,TS,VC9 These options need to match in Unknown on line 0 Why it doesn't says that I compiled the module with VC9 ? More info: Operating System: Windows7 x64 PHP: 5.3.3,TS,VC9 Ok, I found the solution: You must add a