lilypond-devel
[Top][All Lists]
Advanced

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

Re: Fix build failure on GNU Hurd (issue 319400043 by address@hidden)


From: Felix Janda
Subject: Re: Fix build failure on GNU Hurd (issue 319400043 by address@hidden)
Date: Sat, 25 Feb 2017 10:16:10 -0500
User-agent: Mutt/1.7.1 (2016-10-04)

The fix probably breaks compilation on everything not using glibc:

get_current_dir_name() is glibc specific, and not available on other
systems, so its invocation should be protected with an #ifdef __GLIBC__
or via an autoconf test.

As indicated in the man page, even on glibc, to use this function a
declaration of _GNU_SOURCE before including the system headers is
necessary. However in the case of lilypond, as a C++ program, this is
not necessary since g++ (and clang++) predefine _GNU_SOURCE.

glibc has an extension to getcwd. (It allocates the buffer when its
first argument is NULL.) Maybe the following works and is more
portable:

 string
 get_working_directory ()
 {
  char *cwd = getcwd (NULL, 0);
#ifdef PATH_MAX
  if (!cwd)
     {
       char scwd[PATH_MAX];
       return string (getcwd (scwd, PATH_MAX));
     }
#endif
  string s(cwd);
  free(cwd);
  return s;
 }



reply via email to

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