Add C
This commit is contained in:
parent
bb10a715c3
commit
f569c4afa9
7 changed files with 60 additions and 0 deletions
2
c/.gitignore
vendored
Normal file
2
c/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.o
|
||||
example
|
3
c/.vscode/extensions.json
vendored
Normal file
3
c/.vscode/extensions.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"recommendations": ["llvm-vs-code-extensions.vscode-clangd"]
|
||||
}
|
8
c/.vscode/settings.json
vendored
Normal file
8
c/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"editor.tabSize": 2,
|
||||
"editor.insertSpaces": false,
|
||||
|
||||
"files.insertFinalNewline": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
}
|
29
c/Makefile
Normal file
29
c/Makefile
Normal file
|
@ -0,0 +1,29 @@
|
|||
CC = gcc
|
||||
CFLAGS = -std=c11 -pedantic
|
||||
LDFLAGS =
|
||||
RM = rm
|
||||
|
||||
SOURCES = $(wildcard src/*.c)
|
||||
OBJETS = $(patsubst %.c,%.c.o,$(notdir $(SOURCES)))
|
||||
|
||||
EXE = example
|
||||
|
||||
%.c.o: src/%.c
|
||||
$(CC) -c $< -o $@ $(CFLAGS) $(DEVFLAGS)
|
||||
|
||||
main: CFLAGS += -O3
|
||||
main: compilation
|
||||
|
||||
dev: CFLAGS += -Wall -Wextra -Wshadow -Wcast-align -Wstrict-prototypes
|
||||
dev: CFLAGS += -fanalyzer -fsanitize=undefined -g -Og
|
||||
dev: LDFLAGS += -fsanitize=undefined
|
||||
dev: compilation
|
||||
|
||||
compilation: $(OBJETS)
|
||||
$(CC) -o $(EXE) $(OBJETS) $(LDFLAGS)
|
||||
|
||||
all:
|
||||
main
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJETS) $(EXE)
|
8
c/includes/example.h
Normal file
8
c/includes/example.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef PROJECT_EXAMPLE_H
|
||||
#define PROJECT_EXAMPLE_H 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void example();
|
||||
|
||||
#endif
|
3
c/src/example.c
Normal file
3
c/src/example.c
Normal file
|
@ -0,0 +1,3 @@
|
|||
#include "../includes/example.h"
|
||||
|
||||
void example() { printf("Hello, world!\n"); }
|
7
c/src/main.c
Normal file
7
c/src/main.c
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "../includes/example.h"
|
||||
|
||||
int main(int argc, char const *argv[]) {
|
||||
example();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue