What version of C does Python do?

From what I understand, the canonical version of Python is written in C89. I'm curious, maybe later to write some extension in C in Python, but I'm a little confused as to which version of C I should use (could not find in the Python documentation). Since Python is on C89, should I have C89 code or does C11 code work too?

+4
source share
1 answer

C, because the language saw only a relatively minor evolution with C89. It is very easy to code at the intersection of C89, C99 and C11, and this is what I would recommend to you (not so much for interacting with Python, which is more at the ABI level, but also as a general practice at the source code level).

At the top of my head, restricting myself to C89, you lose the syntax for (int i=0;…) , variable-length arrays, and complex numbers.

When writing to C99, you lose the ability to declare variables with the implicit int type permitted by C89. That was never a good idea.

C11 makes it clear that some constructs are prohibited if they were ambiguous in previous standards: INT_MIN % (-1) , (0,i++,j) + (0,j++,i) ( discussion ; comments).

The most useful addition introduced in C99 might be a // comment in C ++ style. Almost all compilers already accepted them as an extension before the publication of C99, so there is no reason to refrain from the form that uses them in 2013.

+5
source

Source: https://habr.com/ru/post/1479396/


All Articles