termbox2
termbox2 copied to clipboard
Releases
Can you please start making releases? To be more specific, tagging versions in git and setting SONAME. This would greatly help packaging in Linux distributions.
this is a header-only library so there's no .so and packaging doesn't make sense either. whoever uses it is supposed to copy the header into his source tree and bake the code into a translation unit of his choice.
How to use termbox2 As mentioned above, there are two options: ... 2. Build termbox2 as a library (either make libtermbox.so or make libtermbox.a) and link as normal.
See #40
I dont think this is feasible as long as compile time options like truecolor and egc exist
I dont think this is feasible as long as compile time options like truecolor and egc exist
Can you please elaborate?
termbox2 can be used a library. The tests run as such. I think what git-bruh may mean is that compile-time options of the library can mismatch include-time options of the calling program. For example, if the library is compiled with EGC and the calling program does not define that option before including termbox.h
, at best certain functions will not work as expected, at worst you will segfault. This is because TB_OPT_EGC
and TB_OPT_TRUECOLOR
influence how certain types are defined.
I've added some guards against this in f0ba92634b4d45222b7638addb837b04e6841bba. The library is compiled with TB_LIB_OPTS
which hard-codes a liberal set of options (both EGC and truecolor enabled). The makefile autogenerates termbox.h.lib
by flipping a single #if 0
to an #if 1
which has the same effect as defining TB_LIB_OPTS
. Packagers should make lib && make install_lib
which will install the libraries plus termbox.h.lib
(as termbox.h
) to ensure consistency.
I think termbox2 can work with C++, but when I build it, many errors print out like this:
$ g++ test.cpp -o test
In file included from test.cpp:2:
termbox.h: In function ‘int cap_trie_add(const char*, uint16_t, uint8_t)’:
termbox.h:1962:27: error: invalid conversion from ‘void*’ to ‘cap_trie_t*’ [-fpermissive]
1962 | tb_realloc(node->children, sizeof(*node) * node->nchildren);
| ^
| |
| void*
termbox.h: In function ‘int update_term_size_via_esc()’:
termbox.h:2102:29: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
2102 | char *move_and_report = "\x1b[9999;9999H\x1b[6n";
| ^~~~~~~~~~~~~~~~~~~~~~~~
The test.cpp is just the source code of this project's reamdme.md's synopsis
Thanks.
The code guarded by TB_IMPL is C code only and has to be compiled in a seperate file and linked with main code, only the header code has c++ compatibility
Got it, thank you.
https://github.com/termbox/termbox2/releases/tag/v2.0.0