Multfile C Extensions

Courageous jkraska1 at san.rr.com
Sun May 28 16:35:15 EDT 2000


> since all functions/variables must be static (aside from init)
> how can i get the different files to work with each other?

I don't believe that this is strictly true; the primary
motivation for making all the methods/variables static
is to prevent namespace collision. static declarations
in a single file are therefore WISE, but not required.

> i can work around most of the problems, but the biggest
> one seems to be the initializing stuff.
> 
> is there an example of a C extension out there that is split
> into a couple source files? the biggest problem is i want it
> all in one module...
> 
> urgh, this shouldn't be so tough?
 
Well, the obvious trick, albeit totally ugly, would be to
do something like...

#include "file1.c"
#include "file2.c"
#include "file3.c"

... segmenting all your files together into only one file
which you compile.

The other idea which comes to mind is simply taking extreme
care to manage your symbol space and forgo the use of static
variables. I should point out that some of the harder problems
I've had during my professional career have involved finding
namespace conflicts which the compiler did not detect; a
situation in which the compiler quietly allows a duplicate
symbol to override a previous instance of the symbol in the
symbol space is nightmarish indeed.






C/



More information about the Python-list mailing list