Reputation:
I have the following Makefile:
all: test.c test1.c
gcc -o test test.c -lm
gcc -o test1 test1.c
./test 1000 input.txt
I am getting an error like ./test 1000 input.txt make: *** [run] Error 255
. Is the Makefile correct?
Upvotes: 1
Views: 1924
Reputation: 137398
./test 1000 input.txt make: *** [run] Error 255
This doesn't mean anything is wrong with your Makefile. It means that your ./test
program ran an exited with status 255.
You haven't showed us test.c
, but I'm assuming you didn't write return 255;
. Since the exit status is usually only 8 bits, it's possible you (incorrectly) wrote return -1
. It's also possible that you (incorrectly) omitted a return statement from main
which leads to Undefined Behavior, and -1 happens to be in the return value register (eax
on x86).
You should always enable compiler warnings. To force you to correct them, these warnings (which often indicate broken code) should cause the compilation to fail as well.
CFLAGS = -Wall -Wextra -Werror
test: test.c
$(CC) $(CFLAGS) -o $@ $^
Upvotes: 2