gcc 4.7 programming question related to MythTV

Ralf Corsepius rc040203 at freenet.de
Sun Feb 5 15:14:48 CET 2012


On 02/05/2012 02:20 PM, Richard Shaw wrote:
> I was trying to build the latest 0.24/fixes branch of MythTV and ran
> into an issue where many C files were using functions (usleep, write,
> close, gethostname, etc.) that were not available/(in scope?). It
> turns out that unistd.h provided these functions so I included it in
> all the offending files which allowed building to complete.
>
> Is there any reason this would be unsafe (or non-portable)?
No, nowadays, presuming unistd.h to be present is pretty safe, because 
it has been part of POSIX for ages and is likely present on all POSIX'sh 
environments.

c.f.:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

Somewhat oversimplified, in practice, this means, #include <unistd.h> is 
safe except on Windows.

Whether a particular version of <unistd.h> will provide the missing 
decls, is a different story.
  Some (ancient) OSes still could be shipping ancient or broken versions 
of unistd.h which do not supply the decls current POSIX would expect 
unistd.h to supply. However, this would not be worse than the current 
situation - Compilers could continue to complain about missing 
symbols/decls.

Ralf



More information about the rpmfusion-developers mailing list