3

According to the Python documentation, when compiling a Python extension on Windows, "you should use the same version of VC++ that was used to build Python itself". The explanation usually given is that the mismatch in VC runtime version will cause problems. However, it is possible to compile extensions using newer Visual Studio versions that appear to work just fine.

What are the cases where the different runtimes would cause problems? The most information I've seen on this topics was this thread on the python-dev mailing list. Is there a (hopefully small) set of use cases that lead to problematic behavior, or is it just a matter of luck that I haven't run into any trouble yet?

Ray
  • 4,531
  • 1
  • 23
  • 32

1 Answers1

1

That mailing thread is the most comprehensive list that I've seen of cases where mismatched C runtimes causes problems. The general problem is each runtime doesn't share anything with the other runtime, each has its own separate state, and anything they expose externally can't be shared between the runtimes by your own code. The former problem means that each runtime has its own errno and the second the means that you can't use FILE *' objects opened with one runtime with the file I/O functions of the other.

Enumerating all the possible problems would mean enumerating the entire visible state (including indirectly visible state) of the of the runtimes, and then enumerating every value they can generate and receive that might be incompatible.

Somewhat offsetting this though is Microsoft's promise that object files (.OBJ) compiled with one version of the Microsoft C/C++ compiler should be compatible with subsequent versions of the compiler. This means for example, two different runtimes won't use a completely different set of values for errno (eg. ENOENT is always 2) because those values will appear as constants in object files.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112