Martin Wilck Martin.Wilck@fujitsu-siemens.com writes:
Very true. Perhaps the practical way would be to assume HAVE_GETPWUID == HAVE_GETPWNAM and see whether someone with a really strange platform complains (but see below).
There's no reason to do that, it's trivial to check for both. If you use getpwnam() check for HAVE_GETPWNAM, if you use getpwuid() check for HAVE_GETPWUID. Simple, logical, and works even on strange platforms.
Of course. It was so obvious that I missed it. :-)
Still I think the code should verify that any assumptions made str really true, if possible. Like:
#if defined(HAVE_GETPWUID) || defined(HAVE_GETPWNAM) || defined(HAVE_GETPWENT) # if !(defined(HAVE_GETPWUID) && defined(HAVE_GETPWNAM) && defined(HAVE_GETPWENT)) # error All or none of the functions getpwuid, getpwnam and getpwent are assumed to exist # endif #endif
Patrik Stridvall ps@leissner.se writes:
Still I think the code should verify that any assumptions made str really true, if possible. Like:
#if defined(HAVE_GETPWUID) || defined(HAVE_GETPWNAM) || defined(HAVE_GETPWENT) # if !(defined(HAVE_GETPWUID) && defined(HAVE_GETPWNAM) && defined(HAVE_GETPWENT)) # error All or none of the functions getpwuid, getpwnam and getpwent are assumed to exist # endif #endif
There is absolutely no reason to do that, because we shouldn't assume anything like that. As I said, if you use getpwnam() you check for HAVE_GETPWNAM; whether getpwuid() also exists or not is completely irrelevant.