views:

234

answers:

3

When porting unix project developed in C language to windows and compiling it with VS 2005, compiler reports errors related to incorrect type conversion like " can not convert 'const char*' to 'char*' ". Is it possible to disable this strong checking through compiler options.

-Thanks for attention

+1  A: 

I'm pretty sure, you only need to set the "Compile as C" commandline option (/TP). I'm not entirely familiar with ANSI-C (Over ANSI-C++) but i'd strongly recommend converting it to be type safe regardless. Why return a const and then ignore this fact?

Goz
A: 

I'm not sure you can - it may be the case that the C code isn't valid (and the Unix compiler you're using incorrectly allows it). You can disable warnings, but I don't think you can disable specific errors.

If you haven't already, you can change the project options to compile as C instead of C++ (Prpoerties -> Config Properties -> C/C++ -> Advanced) but I don't think that'll help.

If you can compile as C++, const_cast might be able to help: http://msdn.microsoft.com/en-us/library/bz6at95h(VS.80).aspx

Steve Mc
+1  A: 

Assuming your code is valid C (C89, specifically, since VC++ doesn't support C99), it will be automatically disabled if you either name the file with a .c extension, or in project properties, set it to "Compile as C"

That should disable all C++-specific features and type checks.

jalf
jalf, it worked and able to disable type related errors. Planned to correct all the type related to errors before moving to C++ as Goz recommended.Thanks for answers.
Suresh