Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange interaction with standard headers in C99 mode with GCC #4

Open
ghost opened this issue Sep 6, 2019 · 3 comments
Open

Strange interaction with standard headers in C99 mode with GCC #4

ghost opened this issue Sep 6, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 6, 2019

I was having trouble getting swrap to compile in C99 mode with GCC, but then I put

#undef _DEFAULT_SOURCE
#define _DEFAULT_SOURCE 1

at the top of a .c file that #includes swrap.h and it worked. Sources: 1 2

When something like stdio.h is included, it doesn't work by simply putting the snippet in or directly above the #include of swrap.h. You have to put the snippet above all includes in the translation unit to be safe.

I have attached a test case. Try compiling it both ways.
swrap_c_test.zip

@BareRose
Copy link
Owner

BareRose commented Sep 6, 2019

Neat, will have a closer look at that weirdness when I can. Hopefully a solution can be found that won't require awkwardly redefining _DEFAULT_SOURCE everywhere.

What version of GCC and what specific OS are you using BTW?

@ghost
Copy link
Author

ghost commented Sep 6, 2019 via email

@ghost
Copy link
Author

ghost commented Sep 6, 2019

GCC 7.4.0. But I'm not sure if this is a bug in GCC; it also fails with Clang. Clang does use GCC headers though, so maybe.

It compiles just fine with TCC, and I don't know where TCC's headers come from on Linux. TCC is more of a pure C compiler that I have a fondness for, but it has to work in GCC and Clang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant