diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..a76b0bd --- /dev/null +++ b/.clang-format @@ -0,0 +1,11 @@ +BasedOnStyle: Google +UseTab: Never +IndentWidth: 4 +TabWidth: 4 +BreakBeforeBraces: Attach +AllowShortIfStatementsOnASingleLine: false +IndentCaseLabels: true +ColumnLimit: 0 +AccessModifierOffset: -4 +NamespaceIndentation: All +FixNamespaceComments: false diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..e7be43c --- /dev/null +++ b/.clangd @@ -0,0 +1,11 @@ +CompileFlags: + Add: + - -DLOCAL + - -D_GLIBCXX_DEBUG + - -std=c++23 + - -Wall + - -Wextra + - -Werror=uninitialized + - -Werror=return-type + - -Wno-unused-const-variable + - -Wno-sign-compare diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8275daa --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/gmon.out +/out.txt +/in.txt +/tmp/ \ No newline at end of file diff --git a/.pch.cpp b/.pch.cpp new file mode 100644 index 0000000..6989ae5 --- /dev/null +++ b/.pch.cpp @@ -0,0 +1 @@ +#include \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..352bf7f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,30 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "(gdb) 启动", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/tmp/${fileBasenameNoExtension}", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "为 gdb 启用整齐打印", + "text": "-enable-pretty-printing", + "ignoreFailures": false + }, + { + "description": "将反汇编风格设置为 Intel", + "text": "-gdb-set disassembly-flavor intel", + "ignoreFailures": false + } + ], + "preLaunchTask": "C/C++: make" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..1f37ed1 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: make", + "command": "make", + "args": [ + "SRC=${fileBasename}" + ], + "group": { + "kind": "build", + "isDefault": true + } + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c683213 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +CXX := clang++ +CXXFLAGS := -fdiagnostics-color=always -g \ + -Wall -Wextra \ + -Werror=uninitialized \ + -Werror=return-type \ + -Wno-sign-compare \ + -Wno-unused-const-variable \ + -fsanitize=undefined \ + -D_GLIBCXX_DEBUG \ + -pg \ + -DLOCAL \ + -std=c++23 \ + -pipe + +SRC ?= template.cpp +TARGET := tmp/$(basename $(notdir $(SRC))) +PCH := tmp/precompiled.pch +PCH_HEADER := .pch.cpp + +all: $(TARGET) + +$(TARGET): $(SRC) $(PCH) | tmp + $(CXX) $(CXXFLAGS) -include-pch $(PCH) $(SRC) -o $(TARGET) + +tmp: + mkdir -p tmp + +$(PCH): $(PCH_HEADER) | tmp + $(CXX) $(CXXFLAGS) -x c++-header $(PCH_HEADER) -o $(PCH) + +clean: + rm -rf tmp + diff --git a/template.cpp b/template.cpp new file mode 100644 index 0000000..11357ea --- /dev/null +++ b/template.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +using int64 = long long; +const int64 inf = 0x3f3f3f3f; +const int64 INF = 0x3f3f3f3f3f3f3f3f; +const int Mod = 1e9 + 7; +const int N = 3e5 + 10; + +void solve() { + cout << "Hello world" << '\n'; +} + +signed main() { +#ifndef LOCAL + ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); +#endif + int t = 1; + // cin >> t; + while (t--) + solve(); + return 0; +} \ No newline at end of file