[sane-devel] Internal getopt opinions
Chris Bagwell
chris at cnpbagwell.com
Tue Feb 3 02:10:13 UTC 2009
Hi all,
I'm trying to improve the way I modified the getopt.c to always be
compiled... It has a problem, as pointed out by Mattias, that it
requires some ordering issues with config.h. I'm seeking opinions
before proceeding just to be safe.
In case people didn't catch it, I've modified lib/getopt*.c to *always*
compile now on any platform and have it do some #define magic to prefix
it with sanei_ (as not to conflict with platform versions). The #define
magic has issues with platforms that have getopt defined in stdio.h
though and requires moving stdio.h before #include "config.h"... There
are some things in config.h that make having any #include's before
"config.h" a bad idea. So I have a circular logic bug I need to break.
Fixes boil down to 2 options:
1) Go back to conditionally compiling getopt*.c but to do this right, I
need to also rename include/getopt.h. Right now, there is no way to
include platform's <getopt.h> because of -L../include and there are
conflicting prototype issues in todays <getopt.h> compared to what can
be linked in from platform. Pros: This approach aligns with lalloca.h,
lassert.h, and _stdint.h. Cons: a) To keep CVS history, someone would
need access to backend of CVS server. b) it wasn't correctly
conditionally compiling before for Solaris/Darwin and I'll need to
create some new configure.in logic.
2) Continue to always compile getopt*.c files and update the header
file. Instead of using #define magic to add sanei_ prefixes, manually
change the prototypes to include it. Thats around 5 variables and 5
functions in header to add sanei_ to and 5 #define's added to each
source file. Pros: No configure support to maintain for various
platforms. Cons: Its deviating alot from standard getopt* files and
will be harder to port any updates.
Chris
More information about the sane-devel
mailing list