Python + Borland - msvcrt = grr.

Stephen Hansen news at myNOSPAM.org
Tue Apr 24 00:54:46 EDT 2001


Oh, I'm not sugguesting changing it. Too much work for a no-gain, and I
rather like initializing variables.. just in case. :) My question was just
one of confusion, as I can't imagine a warning that any compiler would raise
if the code _was_ edited, but Fredrik Lundh mentioned one, so I was curious
as to the circumstances.

As for the pragma -- I'm not sure if that's a better idea then just turning
it off in the makefiles/projects i'm using, which I'm intending on doing.

--S

"Neil Hodgson" <nhodgson at bigpond.net.au> wrote in message
news:dn3F6.11623$ff.82511 at news-server.bigpond.net.au...
> Stephen Hansen:
>
> >  PyObject* retval = NULL;
> >         if (!PyArg_ParseTuple(args, ":buffer_info"))
> >                 return NULL;
> >  retval = PyTuple_New(2);
>
>    This is a case where I feel that the code is better written as-is
rather
> than rewriting it to avoid the BCC warning as it is more likely to
continue
> to achieve consistent results after editing. Its better to initialise all
> variables upon declaration as the code can not then rely on uninitialised
> values which lead to random behaviour. Reproducibility should be a goal as
> unreproducible errors are a great way of wasting huge amounts of debug
time.
>
>    If this was C++ rather than C, then it would be even better to move the
> declaration and initialisation to the first assignment as this decreases
the
> scope of retval making it less likely to be abused.
>
>    If there are a lot of these warnings, then the appropriate pragma can
be
> used:
> #ifdef __BORLANDC__
> // Borland warns that values are assigned but never used.
> // This is OK in this code so turn off the warning.
> #pragma warn -aus
> #endif
>
>    Neil
>
>
>





More information about the Python-list mailing list