Python/C interface proposals

Samuel A. Falvo II kc5tja at garnet.armored.net
Wed May 3 16:08:06 EDT 2000


In article <slrn8h0d1m.d23.hat at se-46.wpa.wtb.tue.nl>, Albert Hofkamp wrote:
>I would split the two in 2 definitions:
>
>struct Name { ...};
>typedef struct Name Name;
>
>My gcc compiler does not complain about the double use of the name, so
>at least one compiler allows it.

For my sources, I segregate "classes" of definitions in a header file.  At
the very top, before any structs, I have my typedefs:

typedef struct Stream__imp Stream__imp;
typedef struct Stream__epv Stream__epv;

and so on.  This way, when it comes time to define the structure:

struct Stream__imp
{
   Stream__epv *	_epv;
   Blah			blort;
   Foo			bar[3];
};

I find this to be an incredibly more readable way to structure C header
files, and even allows for a very quick and easy way to make the header
files C++-ified with only *one* set of #ifndef/#endif constructs, again,
further enhancing readability.

#ifndef __cplusplus		(or whatever it is -- I forgot)
typedef struct Stream__imp Stream__imp;
typedef struct Stream__epv Stream__epv;
#endif

-- 
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA



More information about the Python-list mailing list