[Tutor] Compiling a program ::Embedding Python in C

Alan Gauld alan.gauld at btinternet.com
Tue Feb 13 09:44:29 CET 2007

"Shadab Sayani" <shadabsayani at yahoo.com> wrote 

I can't help with the compile issues but a couple of quick points...

> I have a C program mm.c calling python function as
> follows::
> #include "Python.h"
> #include <stdio.h>
> int main(int argc, char* argv[])
> {
>        double answer = 0;
>        PyObject *modname, *mod, *mdict, *func,
> *stringarg, *args, *rslt;

Please, initialise your variables! 
The single most common cause of 'random' bugs in C code is 
uninitialised pointers. Even though you use them safely below 
it's oh so easy to make a change later that tests a pointer 
value before its been set. Much better to *always* initialise 
pointers to NULL.

Alan G.
(3 years a C maintenance team lead ;-( )

More information about the Tutor mailing list