As everybody knows, C standard require to declare variables at the top of function body.
C++ allows to declare it anywhere, just before it will be used.
MSVC follow standard when work with .c and .cpp source files.
GCC allows to declare variables anywhere in function body even if source file is .c
I have a huge number .c files compiling well in GCC and not in MSVC due to this. I can’t rename all them to .cpp.
Is there any simple way to tell MSVC compiler to treat .c file as C++ ones?
C89 standard required that. Current C99 one doesn’t. Anyway, the switch is
/TPto treat all the input files as C++ and/Tp<file>to treat a select one — keep in mind that this might not fix anything, but also introduce new errors and it will mangle the names, so interop might be hurt.The best solution would be to simply compile the C part with GCC.