b-em
b-em copied to clipboard
build issues when cpp calling to c in debugger_symbols
I'm trying to get b-em built on fedora 37, but even after ensuring I have both development libs for zlib and allegro 5.2, I'm receiving the following error. This is apparently when CPP code for debugger symbols encounters a malloc call. Adding includes for cstdlilb where specified did not alleviate the problem, sadly!
In file included from /usr/include/c++/12/ext/string_conversions.h:41,
from /usr/include/c++/12/bits/basic_string.h:3960,
from /usr/include/c++/12/string:53,
from debugger_symbols.h:29,
from debugger_symbols.cpp:4:
/usr/include/c++/12/cstdlib:151:11: error: ‘malloc’ has not been declared in ‘::’
151 | using ::malloc;
| ^~~~~~
debugger_symbols.h: In constructor ‘symbol_entry::symbol_entry(const char*, uint32_t)’:
debugger_symbols.h:48:30: error: ‘malloc’ was not declared in this scope
48 | symbol = (char *)malloc(strlen(_symbol) + 1);
| ^~~~~~
debugger_symbols.h:30:1: note: ‘malloc’ is defined in header ‘<cstdlib>’; did you forget to ‘#include <cstdlib>’?
29 | #include <string>
+++ |+#include <cstdlib>
30 |
In file included from cpu_debug.h:6,
from debugger_symbols.cpp:6:
/usr/include/c++/12/stdlib.h: At global scope:
/usr/include/c++/12/stdlib.h:65:12: error: ‘malloc’ has not been declared in ‘std’
65 | using std::malloc;
| ^~~~~~
debugger_symbols.cpp: In function ‘bool symbol_find_by_name(symbol_table*, const char*, uint32_t*, const char**)’:
debugger_symbols.cpp:143:23: error: ‘malloc’ was not declared in this scope
143 | char *n = (char *)malloc(i + 1);
| ^~~~~~
debugger_symbols.cpp:7:1: note: ‘malloc’ is defined in header ‘<cstdlib>’; did you forget to ‘#include <cstdlib>’?
6 | #include "cpu_debug.h"
+++ |+#include <cstdlib>
7 |
make[1]: *** [Makefile:2390: debugger_symbols.o] Error 1
Do you know which compiler this is using, i.e. gcc (g++) or clang?
Could you try adding #include <cstdlib> to debugger_symbols.h, probably in the part that makes reference to malloc so, for example, before #include <map> and #include <string>.