bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about correct usage of gnulib


From: Bruno Haible
Subject: Re: question about correct usage of gnulib
Date: Tue, 3 May 2011 23:57:38 +0200
User-agent: KMail/1.9.9

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.

Bruno
-- 
In memoriam Zbigniew Iwański <http://en.wikipedia.org/wiki/Henryk_Iwański>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]