Skip to content

Commit 15613da

Browse files
authored
Fix include paths and declare extern VM
Updated include paths for headers and fixed 'vm undeclared' error.
1 parent b007820 commit 15613da

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/runtime/object.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1+
/* src/runtime/object.c */
12
#include <stdio.h>
23
#include <stdlib.h>
34
#include <string.h>
45

5-
#include "memory.h"
6-
#include "object.h"
7-
#include "value.h"
8-
#include "vm.h"
9-
#include "chunk.h" // <--- ADD THIS (Needed for initChunk)
6+
#include "../include/memory.h"
7+
#include "../include/object.h"
8+
#include "../include/value.h"
9+
#include "../include/vm.h"
10+
#include "../include/chunk.h"
11+
12+
// This is the critical fix for the "vm undeclared" error:
13+
extern VM vm;
1014

1115
#define ALLOCATE_OBJ(type, objectType) \
1216
(type *)allocateObject(sizeof(type), objectType)
1317

1418
static Obj *allocateObject(size_t size, ObjType type) {
1519
Obj *object = (Obj *)reallocate(NULL, 0, size);
1620
object->type = type;
17-
object->next = vm.objects;
21+
object->next = vm.objects; // Now works because 'vm' is declared extern above
1822
vm.objects = object;
1923
return object;
2024
}

0 commit comments

Comments
 (0)