[Python-Dev] Windows build broken, Unix dweeb should fix

Tim Peters tim.one@home.com
Wed, 8 Aug 2001 02:21:05 -0400


....\Python\bltinmodule.c(595) : warning C4013: 'S_ISDIR' undefined;
   assuming extern returning int

on the last line here:

	/* Test for existence or directory. */
	if (!stat(filename, &s)) {
		if (S_ISDIR(s.st_mode))

and later it fails to link cuz S_ISDIR doesn't exist.

Now bltinmodule.c doesn't even include <sys/stat.h>, so I don't know why
we'd *expect* the new code to work (although I know why *I* would expect it
to work <wink> -- see below).

getpath.c does import sys/stat.h, then hides this stuff 100 lines later:

#ifndef S_ISREG
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)

#ifndef S_ISDIR
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)

import.c doesn't even trust S_IFMT to work:

#if defined(PYCC_VACPP)
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */

#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)

Out-of-synch preprocessor-trick duplication like this is Major Evil, and I
don't want to see some bastard child of those duplicated into bltinmodule.c
too.  Windows doesn't define S_ISDIR, so at least that macro is needed.  The
only fellow doing an OS/2 port I know of now is Andrew MacIntyre, and I
happen to know that, as of Tuesday <wink>, he neither uses nor has access to
a VisualAge C compiler -- so no telling whether the PYCC_VACPP silliness is
still needed.  I'd drop it!

Who wants to move this crap into pyport.h?  I would, but I don't want to
break the Unix builds, or research 57 varieties of Unix spellings.  pyport.h
already #includes <sys/stat.h> on Windows, so for Windows it suffices to add
just the macros there (assuming these macros are worth the trouble of
defining at all -- S_ISDIR() is only used once in each of these files, and I
don't happen to find S_ISDIR(x) any clearer than its expansion).