Compare commits

..

3 Commits

Author SHA1 Message Date
14001389ac Add basic instructions to README 2020-12-02 19:40:18 +01:00
daae332e5e Add clang-format style file and script 2020-12-02 19:39:08 +01:00
7a68b83610 Add simple hello world main + Makefile 2020-12-02 19:37:52 +01:00
5 changed files with 48 additions and 0 deletions

12
.clang-format Normal file
View File

@ -0,0 +1,12 @@
---
BasedOnStyle: LLVM
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakBeforeMultilineStrings: 'true'
IndentWidth: '4'
...

11
Makefile Normal file
View File

@ -0,0 +1,11 @@
CXX = g++
CXXFLAGS = -Wall -O3
program: main.o
$(CXX) $(CXXFLAGS) -o program.out main.o
main.o: main.cpp
$(CXX) $(CXXFLAGS) -c main.cpp
clean :
-rm *.o *.out

View File

@ -1,2 +1,7 @@
# cpp-template
## Instructions
- Formatting: `./format.sh`
- Building: `make`
- Running: `./program.out`

7
main.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <iostream>
int main() {
std::cout << "Hello World!" << std::endl;
return 0;
}

13
tools/format.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
clang_format_command="clang-format"
clang_tidy_command="run-clang-tidy"
fi
if [[ "$OSTYPE" == "linux"* ]]; then
clang_format_command="clang-format-11"
clang_tidy_command="run-clang-tidy-11"
fi
eval "$clang_format_command -i *.h *.cpp -style=file"
eval "$clang_tidy_command -fix"