[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getlogin on Windows systems
From: |
Bruno Haible |
Subject: |
Re: getlogin on Windows systems |
Date: |
Sat, 9 Jan 2010 13:12:06 +0100 |
User-agent: |
KMail/1.9.9 |
John W. Eaton wrote:
> I'm using the glob module in GNU Octave and a Windows user complained
> that linking failed with an undefined reference to getlogin.
You mean getlogin or getlogin_r?
> The problem appears to be that getlogin_r is called from glob, and the
> gnulib replacement for getlogin_r calls getlogin unconditionally, but
> getlogin doesn't exist on Windows systems.
Looking at the code in lib/glob.c, you see that getlogin_r is not supposed
to be invoked on native Windows platforms (e.g. mingw and MSVC builds):
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
# define WINDOWS32
#endif
...
# ifdef WINDOWS32
/* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference
to HOME, because the user can change HOME. */
...
# else
...
success = getlogin_r (name, buflen) == 0;
# endif
So something must be wrong with the build environment of your user.
> What would be the preferred way of fixing this problem? Should there
> be a separate getlogin module?
No. Who wants getlogin, when getlogin_r is a better interface?
And the glob function does not need the user's name, but his home
directory.
Bruno