Compiling the Python sources with a C++ compiler (aCC)

Michael Geary Mike at DeleteThis.Geary.com
Sun Jun 20 10:18:01 CEST 2004


Paul Sheer wrote:
> I have managed to build Python 2.3.3 with the aCC HP-UX C++
> compiler by making a number of one-line changes. (For reasons
> beyond my control, I am forced to use this compiler and it has
> no C mode at all.)

Nice work! It seems like a good idea to me for Python to be compilable in
either C or C++ mode (not to mention it being a necessity in your case).

>      struct whatzit *p;
> -    p = malloc (sizeof (struct whatzit));
> +    p = (struct whatzit *) malloc (sizeof (struct whatzit));

If that pattern is used a lot, it would be cleaner to use a macro and avoid
the duplication.

Untested, but ought to work:

#define malloc_struct( s )  ( (struct s*)malloc( sizeof(struct s) ) )

struct whatzit* p;
p = malloc_struct( whatzit );

-Mike





More information about the Python-list mailing list