I am making some functions in c which I am going to call from Python via Cython. I am developing these functions in Code:Block using MinGW C++ compiler. But when building them for Python I have to use Visual Microsoft Visual C++ Compiler for Python 2. Then I have met a strang problem. When compiling with Visual C++ compiler I have after a lot of trial and fail found out that all variables have to be decleared before first in each block (if, for, function). Why is so. Are there difference between compilers for c?
2 Answers
In C (proper C rather than C++) the variables have to be declared at the beginning of a block.
1 Comment
Dmitry Rubanovich
@fossekall, MinGW is a C and a C++ compiler. As most compilers, it makes a decision on whether the file it is compiling is supposed to be a C file or a C++ file and then does the compilation. MinGW actually uses a native compiler to do the compilation (unlike gcc which does its own compilation). In case of Windows, that means MinGW is using MS VC++ underneath.
Project > Properties > Configuration properties > C/C++ > Advanced > Compile As. Check that it is set for C++.