mrirecon / bart

BART: Toolbox for Computational Magnetic Resonance Imaging
https://mrirecon.github.io/bart/
BSD 3-Clause "New" or "Revised" License
291 stars 161 forks source link

Compile fail on Mac OS X with gcc12 - conflicting types for 'FILE' #317

Closed JosephGWoods closed 11 months ago

JosephGWoods commented 11 months ago

In commit f210544a58d4ad2f609fcfaf0fb1ef8845f16178, FILE is redefined in src/misc/opts.h as:

typedef struct _IO_FILE FILE;

When compiling with gcc-mp-12, this results in the following error:

CC=gcc-mp-12 make /Library/Developer/CommandLineTools/usr/bin/make MAKESTAGE=2 gcc-mp-12 -Wall -Wextra -Wno-nonnull -Wno-vla-parameter -DUSE_MACPORTS -MMD -MF /PATHTOBART/bart/src/.bart.d -iquote /PATHTOBART/bart/src/ -I/opt/local//include/ -I/opt/local//include -DFFTWTHREADS -DMAIN_LIST="avg, bench, bin, bitmask, cabs, calc, caldir, calmat, carg, casorati, cc, ccapply, cdf97, circshift, conj, conv, conway, copy, cpyphs, creal, crop, delta, ecalib, ecaltwo, epg, estdelay, estdims, estshift, estvar, extract, fakeksp, fft, fftmod, fftrot, fftshift, filter, flatten, flip, fmac, fovshift, homodyne, ictv, index, invert, itsense, join, looklocker, lrmatrix, mandelbrot, measure, mip, mnist, moba, mobafit, morphop, multicfl, nlinv, nlmeans, nnet, noise, normalize, nrmse, nufft, nufftbase, onehotenc, ones, pattern, phantom, pics, pocsense, poisson, pol2mask, poly, reconet, repmat, reshape, resize, rmfreq, rof, roistat, rss, rtnlinv, sake, saxpy, scale, sdot, show, signal, sim, slice, spow, sqpics, squeeze, ssa, std, svd, tensorflow, tgv, threshold, toimg, traj, transpose, twixread, upat, var, vec, version, walsh, wave, wavelet, wavepsf, whiten, window, wshfl, zeros, zexp, ()" -include src/main.h -O2 -Wmissing-prototypes -std=gnu11 -fopenmp -c -o /PATHTOBART/bart/src/bart.o /PATHTOBART/bart/src/bart.c In file included from /PATHTOBART/bart/src/bart.c:26: /PATHTOBART/bart/src/misc/opts.h:176:25: error: conflicting types for 'FILE'; have 'struct _IO_FILE' 176 typedef struct _IO_FILE FILE; ^~~~ In file included from /opt/local/lib/gcc12/gcc/arm64-apple-darwin22/12.3.0/include-fixed/stdio.h:78, from /PATHTOBART/bart/src/bart.c:11: /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/_stdio.h:157:3: note: previous declaration of 'FILE' with type 'FILE' 157 } FILE; ^~~~ /PATHTOBART/bart/src/bart.c: In function 'parse_bart_opts': /PATHTOBART/bart/src/bart.c:158:29: warning: passing argument 1 of 'print_usage' from incompatible pointer type [-Wincompatible-pointer-types] 158 print_usage(stdout, (*argvp)[0], "...", ARRAY_SIZE(opts), opts); ^~
FILE *
/PATHTOBART/bart/src/misc/opts.h:177:31: note: expected 'FILE ' {aka 'struct _IO_FILE '} but argument is of type 'FILE *' 177 extern void print_usage(FILE fp, const char name, const char* usage_str, int n, const struct opt_s opts[n]); ~~^~ /PATHTOBART/bart/src/bart.c: In function 'bart_command': /PATHTOBART/bart/src/bart.c:419:29: warning: assignment to 'FILE ' {aka 'struct _IO_FILE '} from incompatible pointer type 'FILE *' [-Wincompatible-pointer-types] 419 bart_output = fmemopen(buf, (size_t)len, "w"); ^ /PATHTOBART/bart/src/bart.c:435:24: warning: passing argument 1 of 'fclose' from incompatible pointer type [-Wincompatible-pointer-types] 435 fclose(bart_output); // write final nul ^~~
FILE {aka struct _IO_FILE }

/opt/local/lib/gcc12/gcc/arm64-apple-darwin22/12.3.0/include-fixed/stdio.h:157:17: note: expected 'FILE ' but argument is of type 'FILE ' {aka 'struct _IO_FILE '} 157 | int fclose(FILE ); | ^~ make[1]: [/PATHTOBART/bart/src/bart.o] Error 1 make: [default] Error 2

Please note, I use gcc-mp-12 because I cannot install gcc10 using MacPorts - it results in an error. I otherwise follow the other installation instructions in the README using MacPorts. I am using an MacBook Pro with M1 (ARM-based) chip. I do not follow the ARM-based installation instructions (using HomeBrew), because I cannot install gcc-arm-embedded (this requires accessing armkeil.blob.core.windows.net which is a blocked domain in the UK due to suspected malicious activity or malware).