[hashcash] Re: hashcash BSD vs GNU getopt bug (Re: documentation bug?)

  • From: hal@xxxxxxxxxx ("Hal Finney")
  • To: hashcash@xxxxxxxxxxxxx
  • Date: Sat, 28 Aug 2004 12:06:31 -0700 (PDT)

I often struggle with writing cross platform code.  I wonder if anyone
has some good references or resources for this.  I want to write command
line code, or libraries suitable for linking with GUI front ends, which
will compile on Linux, BSD, Windows and Macs.

One useful piece of information would be symbols which are predefined
by the compiler (or preprocessor), for each architecture, that would
allow you to distinguish them reliably.  I don't know a good source
for this.  I have found that _WIN32 is good for identifying Windows
though.

If the symbols exist, you could link your getopt.c module into all builds,
but compile the whole thing under #ifdef BSD or whatever is appropriate.
Or maybe #ifndef GNU, something like that.  The goal would be to have
it compile to nothing on those systems which did not need it, but to
compile to a useful getopt function on systems which could use it.

Actually in this case you could probably just use it all the time,
couldn't you?  I don't see any reason to prefer the system getopt if
the one you have supports all the functions you need.

Hal

Other related posts: