├── bin ├── .gitkeep └── run ├── data ├── .gitkeep ├── raw │ └── .gitkeep ├── input │ └── .gitkeep ├── interim │ └── .gitkeep └── output │ └── .gitkeep ├── docs └── .gitkeep ├── lib └── .gitkeep ├── tests └── .gitkeep ├── src ├── other.c └── main.c ├── include └── other.h ├── .gitignore ├── Makefile ├── LICENSE └── README.md /bin/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/raw/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/input/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/interim/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /data/output/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/run: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JackWetherell/c-project-structure/HEAD/bin/run -------------------------------------------------------------------------------- /src/other.c: -------------------------------------------------------------------------------- 1 | # include 2 | 3 | 4 | int add(int a, int b) 5 | { 6 | return a + b; 7 | } -------------------------------------------------------------------------------- /include/other.h: -------------------------------------------------------------------------------- 1 | #ifndef OTHER_H 2 | #define OTHER_H 3 | 4 | 5 | int add(int a, int b); 6 | 7 | 8 | #endif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # # Ignore the build and lib dirs 2 | # build/* 3 | # lib/* 4 | 5 | # # Ignore any executables 6 | # bin/* -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | --------------------------------------------------------------------------------