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: pkx166h
Subject: Re: Fix build failure on GNU Hurd (issue 319400043 by address@hidden)
Date: Sat, 04 Mar 2017 10:03:37 -0800

On 2017/02/25 15:19:47, felix.janda_posteo.de wrote:
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;
  }

I am going to need some help from a developer on this as not being a
programmer I don't know what that last comment means I need to do on my
side.

Thanks

https://codereview.appspot.com/319400043/



reply via email to

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