tschoonj / xraylib

A library for X-ray matter interaction cross sections for X-ray fluorescence applications
https://github.com/tschoonj/xraylib/wiki
Other
120 stars 54 forks source link

Compile error #232

Open DavidSagan opened 6 months ago

DavidSagan commented 6 months ago

On compiling on Mac using gcc 12.3.0 I get the following error. What is the best way around this?

MAC:~/Bmad/xraylib> make
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in include
make[2]: Nothing to be done for `all'.
Making all in src
  CC       prdata-pr_data.o
  CC       libprdata_la-xrayvars.lo
  CC       libprdata_la-xrayglob.lo
  CC       libprdata_la-xrayfiles.lo
xrayfiles.c: In function 'XRayInitFromPath':
xrayfiles.c:59:45: error: implicit declaration of function 'xrl_strdup'; did you mean 'strdup'? [-Werror=implicit-function-declaration]
   59 |                 MendelArraySorted[i].name = xrl_strdup(MendelArray[i].name);
      |                                             ^~~~~~~~~~
      |                                             strdup
xrayfiles.c:59:43: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   59 |                 MendelArraySorted[i].name = xrl_strdup(MendelArray[i].name);
      |                                           ^
xrayfiles.c:301:32: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  301 |                 error_lines[0] = xrl_strdup(line_name);
      |                                ^
xrayfiles.c:314:53: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  314 |                         error_lines[nerror_lines-1] = xrl_strdup(line_name);
      |                                                     ^
xrayfiles.c:350:32: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  350 |                 error_lines[0] = xrl_strdup(shell_name);
      |                                ^
xrayfiles.c:363:53: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  363 |                         error_lines[nerror_lines-1] = xrl_strdup(shell_name);
      |                                                     ^
xrayfiles.c:461:32: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  461 |                 error_lines[0] = xrl_strdup(line_name);
      |                                ^
xrayfiles.c:474:53: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  474 |                         error_lines[nerror_lines-1] = xrl_strdup(line_name);
      |                                                     ^
xrayfiles.c:517:32: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  517 |                 error_lines[0] = xrl_strdup(auger_name);
      |                                ^
xrayfiles.c:530:53: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  530 |                         error_lines[nerror_lines-1] = xrl_strdup(auger_name);
      |                                                     ^
cc1: some warnings being treated as errors
make[2]: *** [libprdata_la-xrayfiles.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
tschoonj commented 6 months ago

Hi David, good to hear from you!

I am not sure how you ran into that: looking at the code, this is only possible if the SWIG pre-processor macro is defined. Could you attach the config.log file please? Thanks

DavidSagan commented 6 months ago

And good to know that xraylib is alive and well. I use it all the time! -- Cheers, David

config.log

tschoonj commented 6 months ago

Not seeing anything unusual in there at first glance.

Could you re-run your build with make V=1? This should show the full compiler invocations.

Do you have a CFLAGS or CPPFLAGS environment variable set?

DavidSagan commented 6 months ago

I don't have these flags set.

MAC:~/Bmad/xraylib> make V=1
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-recursive
Making all in include
make[2]: Nothing to be done for `all'.
Making all in src
/bin/sh ../libtool  --tag=CC   --mode=compile /opt/local/bin/gcc -DHAVE_CONFIG_H -I. -I..  -I../include -I../include -I..    -Werror=deprecated -Werror=deprecated-declarations -Werror=implicit -Werror=unused-function -Werror=parentheses -Werror=unused-result -g -O2 -MT libprdata_la-xrayfiles.lo -MD -MP -MF .deps/libprdata_la-xrayfiles.Tpo -c -o libprdata_la-xrayfiles.lo `test -f 'xrayfiles.c' || echo './'`xrayfiles.c
libtool: compile:  /opt/local/bin/gcc -DHAVE_CONFIG_H -I. -I.. -I../include -I../include -I.. -Werror=deprecated -Werror=deprecated-declarations -Werror=implicit -Werror=unused-function -Werror=parentheses -Werror=unused-result -g -O2 -MT libprdata_la-xrayfiles.lo -MD -MP -MF .deps/libprdata_la-xrayfiles.Tpo -c xrayfiles.c  -fno-common -DPIC -o .libs/libprdata_la-xrayfiles.o
xrayfiles.c: In function 'XRayInitFromPath':
xrayfiles.c:59:45: error: implicit declaration of function 'xrl_strdup'; did you mean 'strdup'? [-Werror=implicit-function-declaration]
   59 |                 MendelArraySorted[i].name = xrl_strdup(MendelArray[i].name);
      |                                             ^~~~~~~~~~
      |                                             strdup
xrayfiles.c:59:43: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   59 |                 MendelArraySorted[i].name = xrl_strdup(MendelArray[i].name);
      |                                           ^
xrayfiles.c:301:32: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  301 |                 error_lines[0] = xrl_strdup(line_name);
      |                                ^
xrayfiles.c:314:53: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  314 |                         error_lines[nerror_lines-1] = xrl_strdup(line_name);
      |                                                     ^
xrayfiles.c:350:32: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  350 |                 error_lines[0] = xrl_strdup(shell_name);
      |                                ^
xrayfiles.c:363:53: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  363 |                         error_lines[nerror_lines-1] = xrl_strdup(shell_name);
      |                                                     ^
xrayfiles.c:461:32: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  461 |                 error_lines[0] = xrl_strdup(line_name);
      |                                ^
xrayfiles.c:474:53: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  474 |                         error_lines[nerror_lines-1] = xrl_strdup(line_name);
      |                                                     ^
xrayfiles.c:517:32: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  517 |                 error_lines[0] = xrl_strdup(auger_name);
      |                                ^
xrayfiles.c:530:53: warning: assignment to 'char *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
  530 |                         error_lines[nerror_lines-1] = xrl_strdup(auger_name);
      |                                                     ^
cc1: some warnings being treated as errors
make[2]: *** [libprdata_la-xrayfiles.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
tschoonj commented 6 months ago

I am unable to reproduce this, sorry.

If you remove #ifndef SWIG and one of the #endifs in include/xraylib-aux.h, does compilation succeed then?

DavidSagan commented 6 months ago

No change with #ifndef SWIG removed.

DavidSagan commented 6 months ago

Note: This is a recent issue for Mac since in the past I have not had a problem. I am using OS 14.1.2 with Xcode 15.0.1.

DavidSagan commented 6 months ago

If I remove the #ifndef _XRAYLIB_AUX_H the compile gets further.

tschoonj commented 6 months ago

I have been unable to reproduce this. AFAICT this looks like an issue with the preprocessor. Does switching to a different version of GCC (or LLVM/clang) make a difference?