riscv-vm icon indicating copy to clipboard operation
riscv-vm copied to clipboard

Error on Make

Open mateidragony opened this issue 11 months ago • 1 comments

I get a few errors when I call make:

Building CXX object CMakeFiles/riscv_vm.dir/riscv_vm/syscall.cpp.o syscall.cpp: In function ‘void syscall_write(riscv_t*)’:

syscall.cpp:97:29: error: ‘alloca’ was not declared in this scope 97 | uint8_t *temp = (uint8_t*)alloca(count);

syscall.cpp:231:29: error: ‘alloca’ was not declared in this scope 231 | uint8_t *temp = (uint8_t*)alloca(count); | ^~~~~~ make[2]: *** [CMakeFiles/riscv_vm.dir/build.make:104: CMakeFiles/riscv_vm.dir/riscv_vm/syscall.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:196: CMakeFiles/riscv_vm.dir/all] Error 2 make: *** [Makefile:91: all] Error 2

mateidragony avatar Mar 12 '24 02:03 mateidragony

I got the same problem and I had solved it. use

man alloca

you will know the alloca comes from <alloca.h>

so just add this code in syscall.cpp:

#include <cstdint>
#include <cstdio>
#include <ctime>

#include "../riscv_core/riscv.h"
#include "state.h"

#include <alloca.h>    // Add this line

enum {
 SYS_getcwd = 17,

then you will make successful.

ALexei-Stukov avatar Jul 16 '24 11:07 ALexei-Stukov