Platform-Specific Sourcefiles?

Bryce McKinlay bryce@mckinlay.net.nz
Fri Oct 10 03:47:00 GMT 2003


On Oct 10, 2003, at 3:34 PM, Mohan Embar wrote:

> I've asked this question before, but never got a
> response: Is it possible / desirable to put multipurpose,
> platform-specific helper classes in their own
> sourcefiles in order to avoid win32.* and
> posix.* becoming too monolithic? How would this
> work from a configure.in / Makefile.am standpoint?

It might make sense to divide them up a little bit further - for 
example posix-io.cc / win32-io.cc containing platform IO functions - 
file descriptor stuff, etc would probably be good. But, we don't really 
want too many platform specific source files - every file you add adds 
to the library's build time (and the native files generally take a good 
deal longer to compile than the average .java file).

The most important consideration in my opinion is how clean the design 
is and how easily it is to find stuff. So, if there are a bunch of 
functions that are platform specific and clearly fit into a certain 
category, eg I/O, or share a bunch of common resources etc, then we 
should consider an extra file for them.

> There must be a more elegant way to do this than
> to unconditionally compile such files and surround
> them by #ifdef WIN32...#endif guards.

Yep.

Regards

Bryce.




More information about the Java mailing list