migration from Visual studio 6
-
While migrating VC++ code from VS6 (1998) to VS5(later year) I had to remove __STDC__ from project properties-Predecessors. It fix lot of 'tagVariant' related errors. if i have __STDC__ in project properties - preprpcessors I get this xyz.cpp c:\program files (x86)\microsoft visual studio 8\vc\atlmfc\include\atlcomcli.h(443) : error C2039: 'vt' : is not a member of 'tagVARIANT' c:\program files (x86)\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(424) : see declaration of 'tagVARIANT' c:\program files (x86)\microsoft visual studio 8\vc\atlmfc\include\atlcomcli.h(443) : error C2039: 'vt' : is not a member of 'tagVARIANT' Next what happened is function definitions were not recognized in many of the project file. so I added #define
__STDC__
in problem files which also took care of many unrecognized function definition related errors. Now the project is left with only one error in compiling one file which says "Fetal error (1017) invalid integer constant expression in ctype.h" and the code its pointing to line number 362 in ctype.h #define !__STDC__ etc Any ideas - suggestions ? Pls help I tried to - Remove any #define __STDC__ that I added locally. Also remove __STDC__ from Preprocessor definitions if you haven't done so already. Selected all the .c files in the solution explorer and select properties in the solution explorer context menu. In the properties dialog select /Za for C/C++\Language\Disable Language Extensions property. Which took me back to -> error C2065: ‘xyz’: undeclared identifier : error C2182: ‘pqr’ : illegal use of type 'void' : error C2065: ‘some variable’ : undeclared identifier : error C2146: syntax error : missing ';' before identifier ‘classname’ : error C2143: syntax error : missing ';' before '*' : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int : error C2040: ‘variable2’ : 'int *' differs in levels of indirection from ''unknown-type'' . . . Reference : http://social.msdn.microsoft.com/Forums/en-US/e68b0af5-ed25-4953-80e7-e88463149b77/fatal-error-1017-invalid-integer-constant-expression-in-ctypeh-during-migration-from-vs6-to-vs5?forum=vcgeneral
-
While migrating VC++ code from VS6 (1998) to VS5(later year) I had to remove __STDC__ from project properties-Predecessors. It fix lot of 'tagVariant' related errors. if i have __STDC__ in project properties - preprpcessors I get this xyz.cpp c:\program files (x86)\microsoft visual studio 8\vc\atlmfc\include\atlcomcli.h(443) : error C2039: 'vt' : is not a member of 'tagVARIANT' c:\program files (x86)\microsoft visual studio 8\vc\platformsdk\include\oaidl.h(424) : see declaration of 'tagVARIANT' c:\program files (x86)\microsoft visual studio 8\vc\atlmfc\include\atlcomcli.h(443) : error C2039: 'vt' : is not a member of 'tagVARIANT' Next what happened is function definitions were not recognized in many of the project file. so I added #define
__STDC__
in problem files which also took care of many unrecognized function definition related errors. Now the project is left with only one error in compiling one file which says "Fetal error (1017) invalid integer constant expression in ctype.h" and the code its pointing to line number 362 in ctype.h #define !__STDC__ etc Any ideas - suggestions ? Pls help I tried to - Remove any #define __STDC__ that I added locally. Also remove __STDC__ from Preprocessor definitions if you haven't done so already. Selected all the .c files in the solution explorer and select properties in the solution explorer context menu. In the properties dialog select /Za for C/C++\Language\Disable Language Extensions property. Which took me back to -> error C2065: ‘xyz’: undeclared identifier : error C2182: ‘pqr’ : illegal use of type 'void' : error C2065: ‘some variable’ : undeclared identifier : error C2146: syntax error : missing ';' before identifier ‘classname’ : error C2143: syntax error : missing ';' before '*' : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int : error C2040: ‘variable2’ : 'int *' differs in levels of indirection from ''unknown-type'' . . . Reference : http://social.msdn.microsoft.com/Forums/en-US/e68b0af5-ed25-4953-80e7-e88463149b77/fatal-error-1017-invalid-integer-constant-expression-in-ctypeh-during-migration-from-vs6-to-vs5?forum=vcgeneral
__STDC__
is defined by the Microsoft compiler when compiling C files with the /Za option. It is never defined when compiling C++ files. You should not define it somewhere in your code or as project global definition, or edit any system header files. If you have a mixed setup of C and C++ files, you can try to rename the C files to *.cpp to force compilation as C++. Finally you have to fix all errors in your source code by inspecting them and take the appropiate actions. -
__STDC__
is defined by the Microsoft compiler when compiling C files with the /Za option. It is never defined when compiling C++ files. You should not define it somewhere in your code or as project global definition, or edit any system header files. If you have a mixed setup of C and C++ files, you can try to rename the C files to *.cpp to force compilation as C++. Finally you have to fix all errors in your source code by inspecting them and take the appropiate actions.I get that - __STDC__ should be there only with .C files. my application also uses cygwin. I think this C files files were there because of cygwin. forcing .C files as .CPP will it not cause any problem when application makes use of cygwin ? Is it okey if in the .C file property i give an option 'Compile as C++ file' ? Well just an update - It did not work. It gave me tons of syntax errors in my .c/.cpp files.
-
I get that - __STDC__ should be there only with .C files. my application also uses cygwin. I think this C files files were there because of cygwin. forcing .C files as .CPP will it not cause any problem when application makes use of cygwin ? Is it okey if in the .C file property i give an option 'Compile as C++ file' ? Well just an update - It did not work. It gave me tons of syntax errors in my .c/.cpp files.
In most cases there is no problem when compiling C with the C++ compiler. However, there may be errors or warnings when some C specific syntax is not supported by C++. If the C files contain no C++ code you may let them still compiled as C. Using Cygwin is just like using any other C library. An example is the standard C library which functions are commonly called from C++ (e.g. all the strXXX functions).
-
In most cases there is no problem when compiling C with the C++ compiler. However, there may be errors or warnings when some C specific syntax is not supported by C++. If the C files contain no C++ code you may let them still compiled as C. Using Cygwin is just like using any other C library. An example is the standard C library which functions are commonly called from C++ (e.g. all the strXXX functions).
-
In most cases there is no problem when compiling C with the C++ compiler. However, there may be errors or warnings when some C specific syntax is not supported by C++. If the C files contain no C++ code you may let them still compiled as C. Using Cygwin is just like using any other C library. An example is the standard C library which functions are commonly called from C++ (e.g. all the strXXX functions).
-
Jochen - thanks for discussing, this is driving me crazy. Shall I try compiling .CPP file as .C files once ?
Member 10403830 wrote:
You mean I should try compiling .CPP file as .C files once ?
No. That won't work. Just compile them first as they are (the MS compilers uses the file extension to select the compiler). If you have problems with C files, try to compile them as C++. The errors from the C++ files must be solved by you to make the new MS compilers happy. If you get stuck with a specific error, ask here again showing the full error message, the code around the indicated line number, and the definitions of user defined types (e.g. structs and typedefs) if necessary. Note that the errors may be also located in lines before the indicated one. Therefore always have also a look at the previous lines (especially the one before).
-
Member 10403830 wrote:
You mean I should try compiling .CPP file as .C files once ?
No. That won't work. Just compile them first as they are (the MS compilers uses the file extension to select the compiler). If you have problems with C files, try to compile them as C++. The errors from the C++ files must be solved by you to make the new MS compilers happy. If you get stuck with a specific error, ask here again showing the full error message, the code around the indicated line number, and the definitions of user defined types (e.g. structs and typedefs) if necessary. Note that the errors may be also located in lines before the indicated one. Therefore always have also a look at the previous lines (especially the one before).
Jochen, If you have a moment can you please have a look at this thread at msdn : http://social.msdn.microsoft.com/Forums/en-US/e68b0af5-ed25-4953-80e7-e88463149b77/fatal-error-1017-invalid-integer-constant-expression-in-ctypeh-during-migration-from-vs6-to-vs5?forum=vcgeneral[^] I tried that.Error from .cpp files are in thousands...they are of type : error C2065: ‘xyz’: undeclared identifier : error C2182: ‘pqr’ : illegal use of type 'void' : error C2065: ‘some variable’ : undeclared identifier : error C2146: syntax error : missing ';' before identifier ‘classname’ : error C2143: syntax error : missing ';' before '*' : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int : error C2040: ‘variable2’ : 'int *' differs in levels of indirection from ''unknown-type'' Removing them is manually one by one is the only way ? I am jsut trying to compile the code from visual studio 6 to visual studio 2006.
-
Jochen, If you have a moment can you please have a look at this thread at msdn : http://social.msdn.microsoft.com/Forums/en-US/e68b0af5-ed25-4953-80e7-e88463149b77/fatal-error-1017-invalid-integer-constant-expression-in-ctypeh-during-migration-from-vs6-to-vs5?forum=vcgeneral[^] I tried that.Error from .cpp files are in thousands...they are of type : error C2065: ‘xyz’: undeclared identifier : error C2182: ‘pqr’ : illegal use of type 'void' : error C2065: ‘some variable’ : undeclared identifier : error C2146: syntax error : missing ';' before identifier ‘classname’ : error C2143: syntax error : missing ';' before '*' : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int : error C2040: ‘variable2’ : 'int *' differs in levels of indirection from ''unknown-type'' Removing them is manually one by one is the only way ? I am jsut trying to compile the code from visual studio 6 to visual studio 2006.
Don't panic. Most of the errors are sourced by previous ones. If you resolve one many other will vanish. So start always with the very first error for a source file and try to locate the reason. After fixing some errors you may discover that other errors are similar to the already fixed ones. So the work is not as much as expected at first glance. If you don't get an error fixed post the relevant information here as said above.
-
Don't panic. Most of the errors are sourced by previous ones. If you resolve one many other will vanish. So start always with the very first error for a source file and try to locate the reason. After fixing some errors you may discover that other errors are similar to the already fixed ones. So the work is not as much as expected at first glance. If you don't get an error fixed post the relevant information here as said above.
Jochen - to start with small fix at a time i took one .cpp file which has few errors. I removed __STDC__ as you said it should never be used with .CPP file. Without __STDC__ I got this error : cpp(53) : error C3646: 'DWORD' : unknown override specifier xyz.cpp(53) : error C2143: syntax error : missing ';' before '__stdcall' xyzcpp(53) : error C2065: 'somevariable' : undeclared identifier xyz.cpp(54) : warning C4229: anachronism used : modifiers on data are ignored xyz.cpp(54) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int xyz.cpp(54) : error C2365: 'abc_process' : redefinition; previous definition was 'function' xyz.cpp(54) : error C2146: syntax error : missing ';' before identifier 'LPVOID' . . These errors i tried to remove by adding relevant header files : #include ,#include ,#include None of them seems to have any effect on the Output , also tried to refer to these header files with the help of setting the path variable. will you please suggest if it needs any other settings or any other work around.
-
Jochen - to start with small fix at a time i took one .cpp file which has few errors. I removed __STDC__ as you said it should never be used with .CPP file. Without __STDC__ I got this error : cpp(53) : error C3646: 'DWORD' : unknown override specifier xyz.cpp(53) : error C2143: syntax error : missing ';' before '__stdcall' xyzcpp(53) : error C2065: 'somevariable' : undeclared identifier xyz.cpp(54) : warning C4229: anachronism used : modifiers on data are ignored xyz.cpp(54) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int xyz.cpp(54) : error C2365: 'abc_process' : redefinition; previous definition was 'function' xyz.cpp(54) : error C2146: syntax error : missing ';' before identifier 'LPVOID' . . These errors i tried to remove by adding relevant header files : #include ,#include ,#include None of them seems to have any effect on the Output , also tried to refer to these header files with the help of setting the path variable. will you please suggest if it needs any other settings or any other work around.
As already mentioned: Focus on the very first error and ignore all others. The first three errors are in line number 53 of the file xyz.cpp. So you should show us the content of that line and the previous line(s) (at least the line before containing code skipping empty and comment only lines) together with the real error messages (or is 'somevariable' really used there?). To solve the error it may be also helpful to show us the declarations of any functions and types used in that lines that are not in the Windows header files (those decalred in your own or third party header files).
-
As already mentioned: Focus on the very first error and ignore all others. The first three errors are in line number 53 of the file xyz.cpp. So you should show us the content of that line and the previous line(s) (at least the line before containing code skipping empty and comment only lines) together with the real error messages (or is 'somevariable' really used there?). To solve the error it may be also helpful to show us the declarations of any functions and types used in that lines that are not in the Windows header files (those decalred in your own or third party header files).
-
It points to this code in XYZ.cpp : #ifdef __STDC__ DWORD WINAPI process( LPVOID Var1) #else DWORD WINAPI process( Var1) LPVOID Var1; #endif
Then blame the one who has written the code. What you need is
DWORD WINAPI process( LPVOID Var1)
That is valid C++ and C (including ANSI C). The second block is old style K&R C which is not used anymore since about 30 years. If such conditions are used all over your source files, you must remove the conditions and the second block.
-
Then blame the one who has written the code. What you need is
DWORD WINAPI process( LPVOID Var1)
That is valid C++ and C (including ANSI C). The second block is old style K&R C which is not used anymore since about 30 years. If such conditions are used all over your source files, you must remove the conditions and the second block.
yes, this code is ancient. I have not seen like this and everything seems reverse to me. I tried as you said, many errors are reduced. But this is everywhere in the codebase. #ifdef __STDC__ DWORD WINAPI ZI_process_monitor( LPVOID TA_arg ) //#else //DWORD WINAPI ZI_process_monitor( TA_arg ) // LPVOID TA_arg; #endif Now i get this one at many place including the beginning of the file : xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(96) : error C2447: '{' : missing function header (old-style formal list?)
-
As already mentioned: Focus on the very first error and ignore all others. The first three errors are in line number 53 of the file xyz.cpp. So you should show us the content of that line and the previous line(s) (at least the line before containing code skipping empty and comment only lines) together with the real error messages (or is 'somevariable' really used there?). To solve the error it may be also helpful to show us the declarations of any functions and types used in that lines that are not in the Windows header files (those decalred in your own or third party header files).
Yes the code is ancient, everything seems reverse to me. as you suggested i commented second block. #ifdef __STDC__ DWORD WINAPI process( LPVOID Var ) //#else //DWORD WINAPI process( var) // LPVOID var; #endif lot many errors are reduced, now what I get is: xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2059: syntax error : '}' xyz.cpp(46) : error C2143: syntax error : missing ';' before '}' xyz.cpp(196) : error C2059: syntax error : '}'
-
Yes the code is ancient, everything seems reverse to me. as you suggested i commented second block. #ifdef __STDC__ DWORD WINAPI process( LPVOID Var ) //#else //DWORD WINAPI process( var) // LPVOID var; #endif lot many errors are reduced, now what I get is: xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2059: syntax error : '}' xyz.cpp(46) : error C2143: syntax error : missing ';' before '}' xyz.cpp(196) : error C2059: syntax error : '}'
It should look like this:
//#ifdef __STDC__
DWORD WINAPI ZI_process_monitor( LPVOID TA_arg )
//#else
//DWORD WINAPI ZI_process_monitor( TA_arg )
// LPVOID TA_arg;
//#endifwhen
__STDC__
is not defined. Finally you should delete all commented lines. -
Yes the code is ancient, everything seems reverse to me. as you suggested i commented second block. #ifdef __STDC__ DWORD WINAPI process( LPVOID Var ) //#else //DWORD WINAPI process( var) // LPVOID var; #endif lot many errors are reduced, now what I get is: xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2447: '{' : missing function header (old-style formal list?) xyz.cpp(46) : error C2059: syntax error : '}' xyz.cpp(46) : error C2143: syntax error : missing ';' before '}' xyz.cpp(196) : error C2059: syntax error : '}'
#if n def __STDC__ DWORD WINAPI process( LPVOID Var ) //#else //DWORD WINAPI process( var) // LPVOID var; #endif it compiled with NO ERRORS. i changed #ifdef to #ifndef to execute DWORD WINAPI process( LPVOID Var ) part of the code - and no errors in compilations.
-
It should look like this:
//#ifdef __STDC__
DWORD WINAPI ZI_process_monitor( LPVOID TA_arg )
//#else
//DWORD WINAPI ZI_process_monitor( TA_arg )
// LPVOID TA_arg;
//#endifwhen
__STDC__
is not defined. Finally you should delete all commented lines. -
It should look like this:
//#ifdef __STDC__
DWORD WINAPI ZI_process_monitor( LPVOID TA_arg )
//#else
//DWORD WINAPI ZI_process_monitor( TA_arg )
// LPVOID TA_arg;
//#endifwhen
__STDC__
is not defined. Finally you should delete all commented lines.my PQR.cpp file which was originally failing at ctype.h line#362 - #if !__STDC__ saying "Compiling...PQR.cpp include\ctype.h(362) : fatal error C1017: invalid integer constant expression for which i went on to fix file xyz.cpp, xyz.cpp got fixed when i undid my __STDC__ related changes and applied your suggestions but the old one PQR.cpp is still breaking with same error at same location :(( I applied your suggestions to PQR.CPP (The real file and real error for which i started all this) also thinking that if XYZ.CPP works PQR.cpp also should work, I can finally get rid of ctype.h but NOOO :(
-
my PQR.cpp file which was originally failing at ctype.h line#362 - #if !__STDC__ saying "Compiling...PQR.cpp include\ctype.h(362) : fatal error C1017: invalid integer constant expression for which i went on to fix file xyz.cpp, xyz.cpp got fixed when i undid my __STDC__ related changes and applied your suggestions but the old one PQR.cpp is still breaking with same error at same location :(( I applied your suggestions to PQR.CPP (The real file and real error for which i started all this) also thinking that if XYZ.CPP works PQR.cpp also should work, I can finally get rid of ctype.h but NOOO :(
Was ctype.h included before or did you add it? If you added it, remove the including. If it was there, check the line with the failure in ctype.h. Check also if the failing code is guarded by some preprocessor definition. A common error would be that some type or definition used by ctype.h is improperly defined somewhere in your header files. You may also move the including of ctype.h on top before inclduing any other file (except stdafx.h if used).