Basilisk parse errors with C macro offsetof()

83 views
Skip to first unread message

Andrew Pollett

unread,
Jun 25, 2025, 9:50:11 AM6/25/25
to basilisk-fr
Hello all,

I am trying to use the C built-in function offsetof() in a basilisk code but I am getting "warning: Basilisk C parse error" from this (I have attached short examples using both Basilisk and regular C). This same syntax works fine in regular C and oddly, the Basilisk code runs and produces the same result (at least in this specific case) as the C code. I don't know if this will produce different results in the future or not. 

To compile the basilisk code, I use:
    CC99='mpicc -std=c99' qcc -O2 -Wall -D_MPI=1 offsetofBasilisk.c -lm

And to compile the regular C code, I use:
    mpicc -O2 -Wall offsetofNative.c -lm

mpicc is using gcc version 13.3.0

If I compile the C code (offsetofNative.c) using the same basilisk compiling command, I still get the error so it is not related to the basilisk include statement. While this short example code doesn't need to be compiled in parallel, the code I am using this in is parallel and so this must work in parallel. However, if the basilisk code is compiled in serial using "qcc -O2 -Wall offsetofBasilisk.c -lm" the parse error still occurs.

My question is, why does this not give any compiler warnings in regular C but does with Basilisk C and what do I have to change to avoid the parse errors?

Thanks for your attention,
Andrew

offsetofNative.c
offsetofBasilisk.c

j.a.v...@gmail.com

unread,
Jun 26, 2025, 4:51:49 AM6/26/25
to basilisk-fr
Hallo Andrew,

I do not know how to solve this, and perhaps you already know this:

The parse "error" may be just a "warning". In your case, an executable is generated (along side a parse error), and it runs fine. (tested without MPI).

Antoon

Op woensdag 25 juni 2025 om 15:50:11 UTC+2 schreef arpo...@gmail.com:

Stephane Popinet

unread,
Jun 26, 2025, 4:59:33 AM6/26/25
to basil...@googlegroups.com
Hi Andrew, Antoon,

> The parse "error" may be just a "warning". In your case, an executable
> is generated (along side a parse error), and it runs fine. (tested
> without MPI).

Yes, it s just a warning as clearly written in the message:

offsetofBasilisk.c:12: warning: ...

offsetof() does not follow the C grammar since it takes a "typedef"
(twoElemStruct) as argument, which is not allowed.

The resulting code should be fine, despite the warning.

cheers,

Stephane


Andrew Pollett

unread,
Jun 26, 2025, 9:57:44 AM6/26/25
to basilisk-fr
Hi Stephane,

Thanks for the clarification. I figured that it would not produce any problems with the code since it does compile and run, but just wanted to clarify that this is indeed the case and the warnings can safely be ignored. 

Thanks again, 
Andrew
Reply all
Reply to author
Forward
0 new messages