Skip to content

Instantly share code, notes, and snippets.

@hidsh
Last active March 17, 2024 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hidsh/0136eb5b98e3a668b68b3d09277e900e to your computer and use it in GitHub Desktop.
Save hidsh/0136eb5b98e3a668b68b3d09277e900e to your computer and use it in GitHub Desktop.
なんか、今日びのgccは個別に -c とかでコンパイルして最後にそいつらをリンクせんでも、1行でソースをコンパイル&リンクしてくれるっぽい
$ ls
Makefile a.out hogelib.c main.c
$ ./a.out
2
$
!!!!!!!!!!!!!まじか!!!!!!!
int inc(int v)
{
return ++v;
}
#include <stdio.h>
extern int inc(int v);
int main(void)
{
int x = inc(1);
printf("%d\n", x);
}
a.out: main.c hogelib.c
gcc -o $@ $^
a.out: main.o hogelib.o
gcc -o $@ $^
main.o: main.c
gcc -o $@ -c $<
hogelib.o: hogelib.c
gcc -o $@ -c $<
@hidsh
Copy link
Author

hidsh commented Dec 1, 2023

いつから??

$ date
Fri Dec  1 17:40:43 JST 2023
$ gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment