Skip to content

Commit eb120e6

Browse files
drafnelgitster
authored andcommitted
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>
1 parent bac59f1 commit eb120e6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compat/fopen.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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
112
#include "../git-compat-util.h"
2-
#undef fopen
13+
314
FILE *git_fopen(const char *path, const char *mode)
415
{
516
FILE *fp;

0 commit comments

Comments
 (0)