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;
 }

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to