@matheusbsbs / matheus-bagliano / commits / eb120e699f
Fork 0

compat/fopen.c: avoid clobbering the system defined fopen macro

Some systems define fopen as a macro based on compiler settings. The previous technique for reverting to the system fopen function by merely undefining fopen is inadequate in this case. Instead, avoid defining fopen entirely when compiling this source file. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Tested-by: Mike Ralphson <mike@abacus.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brandon Casey committed May 7, 2008 at 12:34 UTC eb120e699f3faea2d71cd9cb79a8cf4f79ec1d45
1 file changed +12 -1
compat/fopen.c
+12 -1
@@ -1,5 +1,16 @@
1 +/*
2 + * The order of the following two lines is important.
3 + *
4 + * FREAD_READS_DIRECTORIES is undefined before including git-compat-util.h
5 + * to avoid the redefinition of fopen within git-compat-util.h. This is
6 + * necessary since fopen is a macro on some platforms which may be set
7 + * based on compiler options. For example, on AIX fopen is set to fopen64
8 + * when _LARGE_FILES is defined. The previous technique of merely undefining
9 + * fopen after including git-compat-util.h is inadequate in this case.
10 + */
11 +#undef FREAD_READS_DIRECTORIES
12 #include "../git-compat-util.h"
2 -#undef fopen
13 +
14 FILE *git_fopen(const char *path, const char *mode)
15 {
16 FILE *fp;