[R-pkg-devel] R package build- C compilation issue related to math.h
Vincent Plagnol
v|ncent@p|@gno| @end|ng |rom gm@||@com
Fri Oct 21 08:35:14 CEST 2022
Thank you Andrew for offering to help. The R-hub package sorted me out for
testing for various OSs.
And Ivan: thank you very much- you were spot on. Swapping the order of
config.h and system headers in all my C files made the compilation work in
my R-hub tests. Hopefully ExomeDepth is now about to show up in CRAN (I
just resubmitted). Amazingly insightful advice. I think it's fair to say
that I would never have worked that one out (or it would have taken me
absolutely forever). So thanks a lot for helping, I am really grateful.
And noted re replying in plain text. Gmail does HTML without really telling
that it does HTML but I'll try to stick to plain text in the future.
On Thu, Oct 20, 2022 at 9:35 AM Ivan Krylov <krylov.r00t using gmail.com> wrote:
> On Wed, 19 Oct 2022 23:39:57 +0100
> Vincent Plagnol <vincent.plagnol using gmail.com> wrote:
>
> > gcc-12 -I"/home/hornik/tmp/R/include" -DNDEBUG -I/usr/local/include
> > -DUSE_TYPE_CHECKING_STRICT -D_FORTIFY_SOURCE=2 -fpic -g -O2 -Wall
> > -Wstrict-prototypes -pedantic -mtune=native -c VP_gamma.c -o
> > VP_gamma.o
>
> > /usr/include/x86_64-linux-gnu/bits/mathcalls.h:85:1: error:
> > expected ‘;’ before ‘extern’
>
> > It is painful to debug because I don't have a debian machine.
> > Furthermore the issue seems to be in the file called at line 22 of
> > gsl_math.h which is #include <math.h>
>
> For what it's worth, I couldn't reproduce the problem when compiling
> VP_gamma.c from https://github.com/vplagnol/ExomeDepth on two of my
> Debian machines with older GCC versions; you might actually need GCC 12
> to see it.
>
> I see that VP_gamma.c includes config.h before including gsl_math.h.
> Typically, config.h should be automatically generated by the configure
> script and may contain different definitions on different systems.
> Somebody else has a similar problem, also in math.h, also with a file
> that includes config.h before math.h:
> https://github.com/vplagnol/ExomeDepth/issues/50
>
> I think that config.h defines something in its /* Substitute gsl
> functions for missing system functions */ section that confuses the
> glibc math.h machinery. If you have to include config.h in a source
> file, it might help to process the system headers first.
>
> I had a related problem recently: MinGW was complaining about a
> strftime call in bundled code that wasn't reachable from R anyway, so I
> decided to patch it out using the preprocessor. The correct way to do
> so is to #include the system header first, then re-#define the function
> to nothing:
>
> https://github.com/aitap/Ropj/commit/a7d6cec19d11d47d731fbadbf8735660e534efaa
>
> Otherwise the re-definition affects the system header where the
> function is declared and the result is syntactically invalid.
>
> > [[alternative HTML version deleted]]
>
> Sorry, the mailing list ate the HTML version of your e-mail, and the
> plain text version automatically prepared by your mailer is not easy to
> read: https://stat.ethz.ch/pipermail/r-package-devel/2022q4/008578.html
>
> Please post in plain text.
>
> --
> Best regards,
> Ivan
>
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list