From bfc82e43db4181c35860ea9dc41b9459c1e42e4b Mon Sep 17 00:00:00 2001 From: "Darryl L. Miles" Date: Tue, 8 Oct 2024 08:01:17 +0100 Subject: [PATCH] MacOS: FREAD rename to magicFREAD due to sys/fcntl.h definition Example build issue using MacOS 12 (Xcode 14.2 from MacOSX.platform). In file included from grTk1.c:23: In file included from ../utils/main.h:26: In file included from ../windows/windows.h:26: ../utils/magic.h:143:13: warning: 'FREAD' macro redefined [-Wmacro-redefined] #define FREAD(a,b,c,d) gzread(d,a,b*c) ^ /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/fcntl.h:110:9: note: previous definition is here #define FREAD 0x00000001 --- calma/CalmaRdio.c | 4 ++-- calma/CalmaWrite.c | 4 ++-- utils/magic.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/calma/CalmaRdio.c b/calma/CalmaRdio.c index 079b1f3d..b0f31d72 100644 --- a/calma/CalmaRdio.c +++ b/calma/CalmaRdio.c @@ -389,7 +389,7 @@ calmaReadStringRecord( nbytes -= CALMAHEADERLENGTH; *str = (char *) mallocMagic(nbytes + 1); - if (FREAD(*str, sizeof (char), nbytes, calmaInputFile) != nbytes) + if (magicFREAD(*str, sizeof (char), nbytes, calmaInputFile) != nbytes) goto eof; *(*str + nbytes) = '\0'; @@ -428,7 +428,7 @@ calmaReadR8( double mantissa, d; bool isneg; - if (FREAD((char *) dchars, sizeof (char), sizeof dchars, + if (magicFREAD((char *) dchars, sizeof (char), sizeof dchars, calmaInputFile) != sizeof dchars) return (FALSE); diff --git a/calma/CalmaWrite.c b/calma/CalmaWrite.c index 3fe6ebc7..33cbe3f7 100644 --- a/calma/CalmaWrite.c +++ b/calma/CalmaWrite.c @@ -1091,7 +1091,7 @@ calmaProcessDef( /* Read the structure name and check against the CellDef name */ defsize = (size_t)(cellstart - structstart); buffer = (char *)mallocMagic(defsize + 1); - numbytes = FREAD(buffer, sizeof(char), (size_t)defsize, fi); + numbytes = magicFREAD(buffer, sizeof(char), (size_t)defsize, fi); if (numbytes == defsize) { buffer[defsize] = '\0'; @@ -1131,7 +1131,7 @@ calmaProcessDef( defsize = (size_t)(cellend - cellstart); buffer = (char *)mallocMagic(defsize); - numbytes = FREAD(buffer, sizeof(char), (size_t)defsize, fi); + numbytes = magicFREAD(buffer, sizeof(char), (size_t)defsize, fi); if (numbytes == defsize) { diff --git a/utils/magic.h b/utils/magic.h index eebcd253..0dcda8e9 100644 --- a/utils/magic.h +++ b/utils/magic.h @@ -146,7 +146,7 @@ extern char AbortMessage[]; #define FOPEN gzopen #define FCLOSE gzclose #define FGETC gzgetc - #define FREAD(a,b,c,d) gzread(d,a,b*c) + #define magicFREAD(a,b,c,d) gzread(d,a,b*c) #define FEOF gzeof #define FSEEK gzseek #define FTELL gztell @@ -157,7 +157,7 @@ extern char AbortMessage[]; #define FOPEN fopen #define FCLOSE fclose #define FGETC getc - #define FREAD fread + #define magicFREAD fread #define FEOF feof #define FSEEK fseek #define FTELL ftello