On 05/03/2011 11:57 PM, Bruno Haible wrote:
Lorenzo Bettini asked:
Would it be correct to put config.h only say in file1.cpp (and use the
ā€˜-Iā€™ option that refers to the Gnulib library directory for that file
only), and not in file2.cpp and file3.cpp (where I don't use -I to refer
to gnulib library directory), and then link all the 3 files together by
also putting -lgnu?
...
what about libraries?
For instance, I can live with including config.h in all .cpp library
files, but I wouldn't add it to library header files.  Header files are
not referring to any struct defined in system header files of gnulib...
at least I guess (basically my library header files only use string form
C++ standard library)...  would that be safe?

As long as your header files refer only to types that are not replaced by
gnulib or autoconf macros, and these types are compiler independent, you're
safe.

The most critical types in this respect are those provided by<stdint.h>  and
<stdbool.h>. If you want header files that can be consumed by any compiler
(e.g. build on Solaris with gcc, and allow the user to use cc on Solaris,
or vice versa), then you need to play some tricks that are not included in
gnulib. libunistring does it like this, with a reduced stdint.h replacement
and a (currently buggy) stdbool.h replacement.

But if you use 'string' from the C++ standard library, then your users are
tied to the compiler (and precise compiler version) you use anyway. In this
case, you can also simply publish the generated stdint.h and stdbool.h
(under different names, or in subdirectories of $(includedir), of course!!).
Also don't forget to sed-replace the double-inclusion guard of these generated
files.

Hi Bruno

actually I see that in the build directory (in the subdirectory where gnulib headers are generated) there's no stdint.h and stdbool.h, so I should be OK, right?

thanks in advance
        Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com



Reply via email to