ggpo
ggpo copied to clipboard
[Arch Linux] compilation fails with "x" not found, did you mean "y"?
log:
[ 6%] Building CXX object src/CMakeFiles/GGPO.dir/lib/ggpo/bitvector.cpp.o
[ 13%] Building CXX object src/CMakeFiles/GGPO.dir/lib/ggpo/game_input.cpp.o
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp: In member function ‘void GameInput::desc(char*, size_t, bool) const’:
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp:44:20: error: ‘sprintf_s’ was not declared in this scope; did you mean ‘sprintf’?
44 | remaining -= sprintf_s(buf, buf_size, "(frame:%d size:%d ", frame, size);
| ^~~~~~~~~
| sprintf
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp:46:20: error: ‘sprintf_s’ was not declared in this scope; did you mean ‘sprintf’?
46 | remaining -= sprintf_s(buf, buf_size, "(size:%d ", size);
| ^~~~~~~~~
| sprintf
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp:52:18: error: ‘sprintf_s’ was not declared in this scope; did you mean ‘sprintf’?
52 | int c = sprintf_s(buf2, ARRAY_SIZE(buf2), "%2d ", i);
| ^~~~~~~~~
| sprintf
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp:53:10: error: ‘strncat_s’ was not declared in this scope; did you mean ‘strncat’?
53 | strncat_s(buf, remaining, buf2, ARRAY_SIZE(buf2));
| ^~~~~~~~~
| strncat
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp:57:4: error: ‘strncat_s’ was not declared in this scope; did you mean ‘strncat’?
57 | strncat_s(buf, remaining, ")", 1);
| ^~~~~~~~~
| strncat
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp: In member function ‘void GameInput::log(char*, bool) const’:
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp:65:9: error: ‘strcpy_s’ was not declared in this scope; did you mean ‘strcpy’?
65 | strcpy_s(buf, prefix);
| ^~~~~~~~
| strcpy
/home/fabx/Desktop/ggpo/src/lib/ggpo/game_input.cpp:67:4: error: ‘strncat_s’ was not declared in this scope; did you mean ‘strncat’?
67 | strncat_s(buf, ARRAY_SIZE(buf) - strlen(buf), "\n", 1);
| ^~~~~~~~~
| strncat
Why the problem is happening
These _s
functions come from a C standard addition termed as "Annex K", which introduces bound checking interfaces for common standard library functions, which are subfixed with _s
(as in safe, secure).
However, Annex K is weird, Windows implemented it, but botched the API, whereas glibc (gcc's standard library) did not even bother, hence your GCC compiler cannot find those functions, they do not exist!
Possible Solution
In order for the application to be portable on compilers other than MSVC, the _s
functions could be substituted with either:
- Proper, modern C++ alternatives (might prove to be slower)
- Their non
_s
alternative with a macro/preprocessor directive (some level of bounds checking would still be provided on GCC thanks to compiler hardening flags) - A more widely accepted but still safer alternative, e.g.:
strncat
instead ofstrcat
,snprintf
instead ofsprintf
, etc...
Why the problem is happening
These
_s
functions come from a C standard addition termed as "Annex K", which introduces bound checking interfaces for common standard library functions, which are subfixed with_s
(as in safe, secure).However, Annex K is weird, Windows implemented it, but botched the API, whereas glibc (gcc's standard library) did not even bother, hence your GCC compiler cannot find those functions, they do not exist!
Possible Solution
In order for the application to be portable on compilers other than MSVC, the
_s
functions could be substituted with either:
- Proper, modern C++ alternatives (might prove to be slower)
- Their non
_s
alternative with a macro/preprocessor directive (some level of bounds checking would still be provided on GCC thanks to compiler hardening flags)- A more widely accepted but still safer alternative, e.g.:
strncat
instead ofstrcat
,snprintf
instead ofsprintf
, etc...
Already tried to port it on my own but there is a specific winapi function thati can't use or recreate even via wine libs
Do you have a line number for the func?
Do you have a line number for the func?
poll.cpp:18:32: error: ‘CreateEvent’ was not declared in this scope
18 | _handles[_handle_count++] = CreateEvent(NULL, true, false, NULL);
| ^~~~~~~~~~~
/home/fabx/Desktop/ggpo/src/lib/ggpo/poll.cpp: In member function ‘bool Poll::Pump(int)’:
/home/fabx/Desktop/ggpo/src/lib/ggpo/poll.cpp:71:10: error: ‘WaitForMultipleObjects’ was not declared in this scope
71 | res = WaitForMultipleObjects(_handle_count, _handles, false, timeout);
| ^~~~~~~~~~~~~~~~~~~~~~
```