On 27/09/2023 17:10, Страхиња Радић wrote:
On 23/09/27 03:50PM, Arthur Jacquin wrote:
termbox2.h is not C99 compliant, yet the -std=c99 compilation flag is
set in the default configuration. On the compilers I tried, it has not
been a problem as the non-C99 parts were ignored, but I shouldn't have
assumed it would always be this way. Sorry for the annoyance.
Which parts of termbox2.h are not C99 compliant? What compiler doesn't
"ignore"
the non-C99 compliant code when -std=c99 is passed?
I maintain my own simple editor called sled[1], which uses termbox2.h
and
passes `-std=c99` as a default flag. I have compiled it using GCC,
Clang/LLVM,
tinycc, on (GNU/)Linux and OpenBSD, and I have yet to encounter any
errors.
I tried compiling your program using `CC=c99` (script wrapper to GCC)
and
passing `-std=c99`, and there are only some warnings about implicitly
declared
functions, nothing about `struct sigaction`. In any case, you can
simply
include the needed headers prior to including termbox2.h (my program
uses
signal.h to redraw after C-Z, so I include it anyway).
[1]: https://strahinja.srht.site/sled/
The whole C99 compliance thing is not perfectly clear to me, and the
clarification is on my todo list. Let me explain what I understand as
of now. If I'm wrong, correct me.
I use tinycc and gcc for testing, with the `-std=c99` flag. Like you,
I've never had any errors, but I get warnings for implicitely
declared functions (with gcc): strerror_r, cfmakeraw, and fileno.
I believe these functions are not in the C99 standard library, if I
refer to this draft[0], and I would like to avoid including
POSIX-specific headers.
So to my understanding, termbox2.h is C99 compliant, but uses
functions that are not part of the C99 standard library, and that's
why I said (incorrectly) that termbox2.h is not C99 compliant.
What I'm not sure about is how these implicitely declared functions
are treated by the linker. As I intend to rewrite the termbox2.h
parts related to these functions, this question is not crucial, and
until the rewrite is done, deleting the `-std=c99` flag should be
enough.
[0]: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf