Skip to content

Support C11 _Thread_local #368

Description

@dmlloyd

It would be nice if scanners could be generated which declare all global variables as _Thread_local. This would allow thread-safe scanners to be generated without having to use the reentrant API.

I tried modifying the skeleton file for this purpose but it seems that the declarations in the generated code are incompatible; you get a couple of errors like this:

target/gensrc/scanner.c:328:21: error: non-thread-local declaration of ‘yyout’ follows thread-local declaration
 FILE *yyin = NULL, *yyout = NULL;
                     ^~~~~
target/gensrc/scanner.c:159:35: note: previous declaration of ‘yyout’ was here
 extern _Thread_local FILE *yyin, *yyout;
                                   ^~~~~

I think if a macro like YY_THREAD_LOCAL would exist with possible values being "_Thread_local" or "", then it would be easy to switch it on and off.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions