On Thu, Jun 2, 2011 at 5:45 AM, Alexandre Raymond <cerb...@gmail.com> wrote: > On OSX > 10.5, daemon() is deprecated, resulting int he following warning: > ----8<---- > qemu-nbd.c: In function ‘main’: > qemu-nbd.c:371: warning: ‘daemon’ is deprecated (declared at > /usr/include/stdlib.h:289) > ----8<---- > > The following trick, used in mDNSResponder, takes care of this warning: > http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-258.18/mDNSPosix/PosixDaemon.c > > Signed-off-by: Alexandre Raymond <cerb...@gmail.com> > --- > qemu-nbd.c | 9 +++++++++ > 1 files changed, 9 insertions(+), 0 deletions(-) > > diff --git a/qemu-nbd.c b/qemu-nbd.c > index e858033..10b0791 100644 > --- a/qemu-nbd.c > +++ b/qemu-nbd.c > @@ -16,6 +16,10 @@ > * along with this program; if not, see <http://www.gnu.org/licenses/>. > */ > > +#if __APPLE__ > +#define daemon fake_daemon_function > +#endif > + > #include <qemu-common.h> > #include "block_int.h" > #include "nbd.h" > @@ -32,6 +36,11 @@ > #include <signal.h> > #include <libgen.h> > > +#if __APPLE__ > +#undef daemon > +extern int daemon(int, int); > +#endif > +
Please introduce a wrapper instead, for example in oslib-posix.c. Then the #ifdeffery is not spread to generic files.