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

cfmakeraw() is a BSD extension, set the needed attributes manually instead #75

Closed
wants to merge 1 commit into from

Conversation

iusevoidbtw
Copy link
Contributor

according to the man page for termios(3), cfmakeraw is a BSD extension.
i'm yet to stumble upon a system that doesn't have it, but it's still non-standard
for instance, when compiling with -std=c99 on my system, gcc complains about implicit declaration of function 'cfmakeraw'

@adsr
Copy link
Contributor

adsr commented Jul 25, 2024

Hello, thanks for the PR. I'm curious what compiler libc version complained about cfmakeraw? I'm guessing a version of libc that didn't recognize _DEFAULT_SOURCE? Does it work if you define _BSD_SOURCE?

Trying to work out if we actually need to fuss over this. We already need _XOPEN_SOURCE for wcwidth which I see no way around unless we bundle something like wcwidth9. There are people using this library on retro / exotic systems that seem to be OK (last I checked).

@iusevoidbtw
Copy link
Contributor Author

thanks for the response! i'm using the musl libc and mainly use gcc 13.2.0, but i've also replicated this warning with clang 17.0.6.

defining _BSD_SOURCE fixes the warning for me.

termios.h on my system contains this:

#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
void cfmakeraw(struct termios *);
int cfsetspeed(struct termios *, speed_t);
#endif

so defining _BSD_SOURCE in termbox2.h can be an alternative fix for musl.

@adsr
Copy link
Contributor

adsr commented Jul 25, 2024

Hm, I wonder why this isn't working for you. That was added a decade ago in musl.

@iusevoidbtw
Copy link
Contributor Author

i think i've figured it out; most musl headers include features.h, which means that including (almost any) header before termbox2.h causes features.h to be included without _DEFAULT_SOURCE, and as such it doesn't define _BSD_SOURCE. later on, after the definition of _DEFAULT_SOURCE, features.h won't be re-included since it already has been included once, meaning that _BSD_SOURCE won't get defined.

this means that including termbox2.h before any other headers also fixes the warning; i've tested it and it does indeed silence the warning. passing -D_DEFAULT_SOURCE to the compiler also fixes the warning.

@adsr
Copy link
Contributor

adsr commented Jul 28, 2024

Thank you @iusevoidbtw. I opened #78 based on your findings. Please have a look.

@adsr adsr closed this Jul 28, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants