|
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.
modified 28-Jul-14 10:59am.
|
|
|
|
|
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).
|
|
|
|
|
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.
|
|
|
|
|
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 <stdlib.h>,#include <windows.h>,#include <stdlib.h> 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).
|
|
|
|
|
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.
|
|
|
|
|
how can i get rid of lot of the below mentioned warnings :
warning C4113: 'int (__cdecl *)()' differs in parameter lists from 'VAR1' ?
Are they serious ?
|
|
|
|
|
To get rid of the warning ensure that the parameter lists of the functions agree.
If this is serious depends on the assignment. It is just a warning and the code will be compiled. But your application may crash when passing incompatible parameters.
You should show the assignment and the definitions.
|
|
|
|
|
below given code in file 'some.c'
--------------------------------
#ifdef __STDC__
static int fun1 ( struct1_inlistfile membervar1, void_pointerinlist_file membervar2 )
#else
static int fun1 (membervar1, membervar2)
struct1_inlistfile membervar1;
void_pointerinlist_file membervar2;
#endif
if the code is as above - I get this warning C4113: 'int (__cdecl *)()' differs in parameter lists from 'RECORDstructinlistheader' file
if i comment the above code like you showed the other day the warning goes away.
.h file has record defination in the form off struct.
the 'some.c' file has another list class defination
static RECORDstructinlistheader Listclass = {
sizeof(RECORD),
sizeof(element in record),
add function ,
search function, /*This is the line where warning is pointed to */
pointer set,
.
.
.
I am afraid I am confusing, but I am giving much details to understand it correctly.
pls help.
|
|
|
|
|
So you did not get the warning when removing the __STDC__ stuff?
Then its should be OK.
To resolve the error check the declaration of search_function and the corresponding RECORDstructinlistheader structure member (structure definition in some header file).
|
|
|
|
|
right no warnings when removing __STDC__ stuff.
I am trying to resolve where is that disagreement happening - but I am confused looking what is the meaning of these four statement ?
typedef int (*p)(void *, void *);
typedef void *P;
typedef void* P;
typedef void* (*p)();
|
|
|
|
|
Swap9 wrote: right no warnings when removing __STDC__ stuff. Then don't care about it.
typedef int (*p)(void *, void *);
typedef void *P;
typedef void* (*p)();
typedef P (*p)();
|
|
|
|
|
|
|
I saw that post but thought it was (partially) solved. When the application uses Japanese Multi Byte characters, support for this characters must be installed in Windows.
The best approach would be converting the application to Unicode. But that might be a lot of work (all char and string literals must be manually rewritten by enclosing them using the _T() macro and the resource strings must be also updated).
|
|
|
|
|
|
I'm sorry but I can't really help you with the language issues due to lack of experience with multi byte projects. Your link seems to describe the problem.
Porting an appplication to Unicode is a lot of work (more than I told you before; I forget to mention additional tasks). If you decide to port your application take special care when reading and writing text file. You may want to let those still use ANSI rather than Unicode.
|
|
|
|
|
Sure, Thanks a lot for responding. I will find out.
|
|
|
|
|
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:
DWORD WINAPI ZI_process_monitor( LPVOID TA_arg )
when __STDC__ is not defined.
Finally you should delete all commented lines.
|
|
|
|
|
Yes got it. absolutely.
Thanks a ton Jochen
|
|
|
|