bit-hack / riscv-vm

A Small RISC-V Virtual Machine
MIT License
72 stars 14 forks source link

Error on Make #5

Open mateidragony opened 8 months ago

mateidragony commented 8 months ago

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

ALexei-Stukov commented 4 months ago

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

man alloca

you will know the alloca comes from

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.