├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bin ├── .gitkeep └── run ├── build ├── main.i ├── main.o ├── main.s ├── other.i ├── other.o └── other.s ├── data ├── .gitkeep ├── input │ └── .gitkeep ├── interim │ └── .gitkeep ├── output │ └── .gitkeep └── raw │ └── .gitkeep ├── docs └── .gitkeep ├── include └── other.h ├── lib └── .gitkeep ├── src ├── main.c └── other.c └── tests └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | # # Ignore the build and lib dirs 2 | # build/* 3 | # lib/* 4 | 5 | # # Ignore any executables 6 | # bin/* -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 Jack Wetherell. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | SRCDIR := src 3 | BUILDDIR := build 4 | TARGET := bin/run 5 | SRCEXT := c 6 | SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT)) 7 | OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.o)) 8 | CFLAGS := 9 | LIB := -L lib 10 | INC := -I include 11 | 12 | $(TARGET): $(OBJECTS) 13 | @echo " Linking..." 14 | @echo " $(CC) $^ -o $(TARGET) $(LIB)"; $(CC) $^ -o $(TARGET) $(LIB) -O3 15 | 16 | $(BUILDDIR)/%.o: $(SRCDIR)/%.$(SRCEXT) 17 | @echo " Building..." 18 | @mkdir -p $(BUILDDIR) 19 | @echo " $(CC) $(CFLAGS) $(INC) -c -o $@ $<"; $(CC) $(CFLAGS) $(INC) -c -o $@ $< -save-temps -O3 20 | 21 | clean: 22 | @echo " Cleaning..."; 23 | @echo " $(RM) -r $(BUILDDIR) $(TARGET)"; $(RM) -r $(BUILDDIR) $(TARGET) 24 | 25 | # Tests 26 | tester: 27 | $(CC) $(CFLAGS) test/tester.cpp $(INC) $(LIB) -o bin/tester 28 | 29 | # Spikes 30 | ticket: 31 | $(CC) $(CFLAGS) spikes/ticket.cpp $(INC) $(LIB) -o bin/ticket 32 | 33 | .PHONY: clean -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # c-project-structure 2 | 3 | Project description 4 | 5 | Project image/gif 6 | 7 | ## Requirements 8 | 9 | Requirements 10 | 11 | ## Installation 12 | 13 | `make` 14 | 15 | ## Usage 16 | 17 | `bin/run` 18 | 19 | ## Example 20 | 21 | `bin/run` 22 | 23 | ## Documentation 24 | 25 | Location of Documentation 26 | 27 | ## Directory structure 28 | ``` 29 | |-- Makefile <- Project makefile 30 | |-- README <- Project README 31 | |-- bin <- Compiled binaries 32 | | `-- run <- Project main executable 33 | |-- build <- Static objects and intermediate files 34 | |-- data <- Project data 35 | | |-- raw <- Raw data 36 | | |-- interim <- Interm data 37 | | |-- input <- Input data 38 | | |-- output <- Output data 39 | |-- docs <- Documentation 40 | |-- include <- Header files 41 | |-- lib <- Dynamic objects 42 | |-- src <- Source files 43 | `-- tests <- Unit tests 44 | ``` 45 | -------------------------------------------------------------------------------- /bin/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/bin/.gitkeep -------------------------------------------------------------------------------- /bin/run: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/bin/run -------------------------------------------------------------------------------- /build/main.i: -------------------------------------------------------------------------------- 1 | # 0 "src/main.c" 2 | # 0 "" 3 | # 0 "" 4 | # 1 "/usr/include/stdc-predef.h" 1 3 4 5 | # 0 "" 2 6 | # 1 "src/main.c" 7 | # 1 "include/other.h" 1 8 | 9 | 10 | 11 | 12 | int add(int a, int b); 13 | # 2 "src/main.c" 2 14 | 15 | 16 | int main() 17 | { 18 | int a = 1; 19 | int b = 1; 20 | int c = add(a, b); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /build/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/build/main.o -------------------------------------------------------------------------------- /build/main.s: -------------------------------------------------------------------------------- 1 | .file "main.c" 2 | .text 3 | .section .text.startup,"ax",@progbits 4 | .p2align 4 5 | .globl main 6 | .type main, @function 7 | main: 8 | .LFB0: 9 | .cfi_startproc 10 | subq $8, %rsp 11 | .cfi_def_cfa_offset 16 12 | movl $1, %esi 13 | movl $1, %edi 14 | call add@PLT 15 | xorl %eax, %eax 16 | addq $8, %rsp 17 | .cfi_def_cfa_offset 8 18 | ret 19 | .cfi_endproc 20 | .LFE0: 21 | .size main, .-main 22 | .ident "GCC: (GNU) 11.1.0" 23 | .section .note.GNU-stack,"",@progbits 24 | -------------------------------------------------------------------------------- /build/other.i: -------------------------------------------------------------------------------- 1 | # 0 "src/other.c" 2 | # 0 "" 3 | # 0 "" 4 | # 1 "/usr/include/stdc-predef.h" 1 3 4 5 | # 0 "" 2 6 | # 1 "src/other.c" 7 | # 1 "include/other.h" 1 8 | 9 | 10 | 11 | 12 | int add(int a, int b); 13 | # 2 "src/other.c" 2 14 | 15 | 16 | int add(int a, int b) 17 | { 18 | return a + b; 19 | } 20 | -------------------------------------------------------------------------------- /build/other.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/build/other.o -------------------------------------------------------------------------------- /build/other.s: -------------------------------------------------------------------------------- 1 | .file "other.c" 2 | .text 3 | .p2align 4 4 | .globl add 5 | .type add, @function 6 | add: 7 | .LFB0: 8 | .cfi_startproc 9 | leal (%rdi,%rsi), %eax 10 | ret 11 | .cfi_endproc 12 | .LFE0: 13 | .size add, .-add 14 | .ident "GCC: (GNU) 11.1.0" 15 | .section .note.GNU-stack,"",@progbits 16 | -------------------------------------------------------------------------------- /data/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/data/.gitkeep -------------------------------------------------------------------------------- /data/input/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/data/input/.gitkeep -------------------------------------------------------------------------------- /data/interim/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/data/interim/.gitkeep -------------------------------------------------------------------------------- /data/output/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/data/output/.gitkeep -------------------------------------------------------------------------------- /data/raw/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/data/raw/.gitkeep -------------------------------------------------------------------------------- /docs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/docs/.gitkeep -------------------------------------------------------------------------------- /include/other.h: -------------------------------------------------------------------------------- 1 | #ifndef OTHER_H 2 | #define OTHER_H 3 | 4 | 5 | int add(int a, int b); 6 | 7 | 8 | #endif -------------------------------------------------------------------------------- /lib/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/lib/.gitkeep -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main() 5 | { 6 | int a = 1; 7 | int b = 1; 8 | int c = add(a, b); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /src/other.c: -------------------------------------------------------------------------------- 1 | # include 2 | 3 | 4 | int add(int a, int b) 5 | { 6 | return a + b; 7 | } -------------------------------------------------------------------------------- /tests/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/b63a19cdba43c11b1cb30a0d1ef53559f1dfdc0b/tests/.gitkeep --------------------------------------------------------------------------------