This commit is contained in:
Mylloon 2023-09-19 11:47:05 +02:00
parent bb10a715c3
commit f569c4afa9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
7 changed files with 60 additions and 0 deletions

2
c/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.o
example

3
c/.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"recommendations": ["llvm-vs-code-extensions.vscode-clangd"]
}

8
c/.vscode/settings.json vendored Normal file
View 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
View 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
View 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
View file

@ -0,0 +1,3 @@
#include "../includes/example.h"
void example() { printf("Hello, world!\n"); }

7
c/src/main.c Normal file
View file

@ -0,0 +1,7 @@
#include "../includes/example.h"
int main(int argc, char const *argv[]) {
example();
return 0;
}