static FILE*

112 views
Skip to first unread message

Bradley Boyd

unread,
Sep 4, 2022, 7:13:02 PM9/4/22
to basilisk-fr
Hello all

qcc doesn't like the use of "staic FILE* fp = ..." anymore. I see in common.h that 

"@define QFILE FILE // a dirty trick to avoid qcc 'static FILE *' rule

What is the qcc 'static FILE*' rule?

Kind regards 

Bradley

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

unread,
Sep 5, 2022, 7:26:42 AM9/5/22
to basilisk-fr
Hallo Bradley,

> qcc doesn't like the use of "staic FILE* fp = ..." anymore.

Do you have an example? More specifically, are you using it outside an `event` function?

An apparent rule is that you cannot use this non-constant static-FILE-pointer-assignment syntax outside `events`...

Antoon
Op maandag 5 september 2022 om 01:13:02 UTC+2 schreef bradley...@gmail.com:

Bradley Boyd

unread,
Sep 5, 2022, 5:52:22 PM9/5/22
to basilisk-fr
Hello Antoon

An example would be 

#include "grid/cartesian.h"

int main() {
    origin(0., 0.);
    init_grid(4);
    static FILE* fp = fopen("out.txt", "w");
    fclose(fp);

}

When I try to compile this code, qcc gives me a seg fault. Obviously, static is not required in this example. I am just curious about the cause of the seg fault.

Kind regards

Bradley

Stephane Popinet

unread,
Sep 6, 2022, 2:35:33 AM9/6/22
to basil...@googlegroups.com
Hi Bradley,

The segfault definitely is a bug. Could you please post a bug report?

http://basilisk.fr/sandbox/bugs/README

Stephane

Bradley Boyd

unread,
Sep 29, 2022, 7:36:22 PM9/29/22
to basilisk-fr
Hello Stephane

Thank you for fixing the bug. However, there is a new error -  "initializer element is not constant". In this case, the initializer is constant 


Cheers

Bradley

Stephane Popinet

unread,
Sep 30, 2022, 3:23:41 AM9/30/22
to basil...@googlegroups.com
> Thank you for fixing the bug. However, there is a new error -
> "initializer element is not constant".

Yes, because you cannot use this syntax outside events.

> In this case, the initializer is constant

No, 'fopen ("file", "w")' is indeed not constant.

cheers,

Stephane


Reply all
Reply to author
Forward
0 new messages