4 ms·
You can just say `make hello` — no Makefile required! And then run with `./hello` instead of invoking the more obscure a.out Obviously that doesn’t scale, but
by gumby 2y ago
You can just say `make hello` — no Makefile required! And then run with `./hello` instead of invoking the more obscure a.out
Obviously that doesn’t scale, but for a beginner it’s simple.
- vdm 2y agoTIL $ ls $ cat >a.c <<EOF int main(){return 42;} EOF $ make a cc a.c -o a $ ./a; echo $? 42 $
- gumby 2y agoI don't know about `ls`, but I typically type something so short on one line: $ echo 'int main(){return 42;}' > a.c; make a && ./a; echo $?
- Too 2y agoThis is because of built in implicit rules in gnu make. https://www.gnu.org/software/make/manual/html_node/Implicit-Rules.html https://www.gnu.org/software/make/manual/html_node/Implicit-... For bigger projects they are considered an anti-pattern and should be disabled (-r), because they can cause all kinds of surprises, (actually, using make to begin with is sortof an anti-pattern) . For example, implicit rules may try to compile using Fortran if it finds a file ending with .f, that's just the tip of the iceberg, getting unexpected outputs or missing outputs is another danger. There are also claims that disabling them can give a performance boost.