'how can I access makefile variable in xv6?
Now I am trying to access makefile variable in my user program in xv6. In other linux system, it can be easily achieved by doing that
- in makefile, define
gcc -D MYVARIABLE=1 ... - in my linux user program, by defining
#include <stdio.h>, I can accessMYVARIABLE.
but in xv6, there is no <stdio.h>. so I can't access MYVARIABLE.
How can I do for access MYVARIABLE??
Solution 1:[1]
Guessing you use this repo: https://github.com/mit-pdos/xv6-public, you can define MYVARIABLE in CFLAGS declaration, near line 83.
CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 -Werror -fno-omit-frame-pointer
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)
# Your macro here
CFLAGS += -DMYVARIABLE=1
In that makefile, there is no %.o: %.c rule: implicit rules are used:
n.ois made automatically fromn.cwith a command of the form$(CC) -c $(CPPFLAGS) $(CFLAGS)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mathieu |
