[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to prefix definitions in config.h
From: |
Guido Draheim |
Subject: |
Re: how to prefix definitions in config.h |
Date: |
Mon, 18 Mar 2002 10:49:50 +0100 |
Es schrieb Clinton Roy:
>
> > > my_config.h: config.h
> > > sed 's/#define /#define MY_/; s/#undef /#undef MY_/' <config.h >$@
>
> It would appear I can air my dirty code :)
>
> We define some of our own defines, that are already prefixed, so we
> have to take care of the case of double prefixing. We also wrap the
> header in an `#ifndef PREFIX_CONFIG_H; #define PREFIX_CONFIG_H ;
> #endif' so we don't have to worry about multiple inclusion.
>
> Finally:
>
> config.h: _config.h
> echo "#ifndef PREFIX_CONFIG_H" > $(output)
> echo "#define PREFIX_CONFIG_H" >> $(output)
> sed -e 's/#define /#define PREFIX_/' \
> -e 's/#undef /#undef PREFIX_/' \
> -e 's/PREFIX_PREFIX_/PREFIX_/' < $(input) >> $(output)
> echo "#endif /* PREFIX_CONFIG_H */" >> $(output)
>
> Pretty icky, but it does get the job done.
>
yes, that was my first shot too ;-) - it's seems to be the canonical
answer to the problem we have to handle and it seems to be a very
common approach to get the job done.
just a hint: after doing some projects with the first attempt of
the prefix-macro, I noticed it would be better to prefix lowercase
entries in config.h with a lowercased prefix, so that for example
off_t maps to my_off_t and const maps to my_const. These examples
are also the case for wrapping the generated my-config.h into another
my-conf.h that looks like:
#ifdef _MSC_VER
#include <msvc-conf.h>
#else
#include <my-config.h>
#endif
#ifndef my_off_t
#define my_off_t off_t
#endif
after here, all the library headers include my-conf.h and use the
my_off_t entry for the function declarations.
well, one might call these just cosmetics but I think it looks
better, or perhaps just *hmmm* more professional *giggle*.
have fun,
-- guido http://freespace.sf.net/guidod
GCS/E/S/P C++/++++$ ULHS L++w- N++@ d(+-) s+a- r+@>+++ y++ 5++X- (geekcode)
Re: how to prefix definitions in config.h, Akim Demaille, 2002/03/18