How to install Python package from source on Windows

bartc bc at freeuk.com
Thu May 18 15:29:49 EDT 2017


On 18/05/2017 19:50, Chris Angelico wrote:

> Now this, however, is more serious. Those warnings scare me, too. (I
> just tried it.) Instead of being "gcc is noisy", these are "your code
> is sloppy". These are exactly why I tell most people NOT to write in
> C. For machine-generated code, this is IMO unacceptable. Maybe
> "-Wno-unused" is okay (machine-generated code often has some junk in
> it), but all the uninitialized variables? No way. Doesn't matter what
> compiler you use, run it in all-warnings-enabled mode at least once as
> part of testing your codegen.

The rules are different when you are writing in a different language and 
only use a C compiler to compile the intermediate code.

Before it becomes C, the code has already been largely verified. C might 
still pick up some things, if the first compiler doesn't check them.

But C is dominated by its ideas of what is undefined behaviour and what 
is implementation defined, which don't match the model used in the 
original language. That language might only be designed for a small set 
of architectures where everything is well defined, whereas C is expected 
to run on every conceivable architecture ever devised.

So the original language can decide that converting a 64-bit pointer (to 
'void') to a 64-bit function pointer is fine, provided there is a cast. 
But C might not like it because on some obscure machine, function 
pointers work differently. You need to do a lot of work to shut up the 
compiler (and it still won't work on that obscure machine).

Bear in mind C allows you to do this:

int *A[10];    // array of pointers to int
int (*B)[10];  // pointer to array of int
int i;

*A[i];         // index then deref to get the int
(*B)[i];       // deref then index to get the int

That's fine so far: one is an array of pointers, other is a pointer to 
an array. However, you can also do this:

(*A)[i];       // deref an array then index
*B[i];         // index a pointer then deref

which is wrong, and can crash the program. A compiler however will not 
detect it as it is perfectly legal, meanwhile it will deluge you with 
hundreds of pointless warnings.

In my original language, such a mixup is illegal. So, do you still trust 
a C compiler more? The language is inherently unsafe.

-- 
bartc



More information about the Python-list mailing list