Skip to content

Commit

Permalink
Start of native C version
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsh committed Oct 13, 2023
1 parent 47f4108 commit a7e83de
Show file tree
Hide file tree
Showing 8 changed files with 492 additions and 1 deletion.
95 changes: 95 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyNamespace: true
SplitEmptyRecord: true
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: false
BreakStringLiterals: true
ColumnLimit: 100
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeCategories:
- Priority: 2
Regex: ^"(llvm|llvm-c|clang|clang-c)/
- Priority: 3
Regex: ^(<|"(gtest|gmock|isl|json)/)
- Priority: 1
Regex: .*
IncludeIsMainRegex: (Test)?$
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ Thumbs.db
# Other
*.bat
node_modules/
build/
25 changes: 25 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"configurations": [
{
"cStandard": "gnu23",
"compilerPath": "/usr/bin/gcc",
"configurationProvider": "ms-vscode.cmake-tools",
"cppStandard": "gnu++23",
"defines": [],
"forcedInclude": [
"${workspaceFolder}/types.h",
"/usr/include/wine-staging-8.13/wine/msvcrt/stdio.h",
"/usr/include/wine-staging-8.13/wine/windows/excpt.h",
"/usr/include/wine-staging-8.13/wine/windows/objbase.h",
"/usr/include/wine-staging-8.13/wine/windows/rpc.h",
"/usr/include/wine-staging-8.13/wine/windows/windows.h"
],
"includePath": [
"/usr/include/wine-staging-8.13/wine/msvcrt",
"/usr/include/wine-staging-8.13/wine/windows"
],
"name": "Linux"
}
],
"version": 4
}
2 changes: 1 addition & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"yaml",
"yml"
],
"ignorePaths": ["*.log", ".directory", ".git", ".vscode/extensions.json"],
"ignorePaths": ["*.log", ".directory", ".git", ".vscode/extensions.json", "build"],
"language": "en-GB",
"languageSettings": [
{
Expand Down
45 changes: 45 additions & 0 deletions .vscode/dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,69 @@
analyzer
appdata
autogen
bindir
cmder
codeql
color
colors
cond
datetime
dcmake
domaain
dword
ehthumbs
esbenp
excpt
fopen
ggdb
gmock
gnucc
gtest
hkcc
hkcr
hkcu
hkey
hklm
hkpd
isort
iwyu
lstatus
macprefs
memb
mktemp
mscgen
msvc
msvcrt
objbase
parens
popen
priv
proc
psscriptanalyzer
pwsh
pylance
qword
reflow
sarif
securestring
strequal
struct
tatsh
udvare
userprofile
wdeprecated
wempty
werror
windres
winprefs
wmissing
wparentheses
wpointer
wshadow
wsign
wswitch
wuninitialized
wunknown
wunreachable
wunused
xapian
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
{
"[c]": {
"editor.tabSize": 4
},
"[powershell]": {
"editor.defaultFormatter": "ms-vscode.powershell"
},
"cSpell.enabled": true,
"cmake.configureArgs": [
"-G",
"Ninja",
"-DCMAKE_C_COMPILER=/usr/lib/mingw64-toolchain/bin/i686-w64-mingw32-gcc",
"-DCMAKE_RC_COMPILER_INIT=/usr/lib/mingw64-toolchain/bin/i686-w64-mingw32-windres=ON",
"-DCMAKE_VERBOSE_MAKEFILE=ON"
],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
Expand Down
48 changes: 48 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cmake_minimum_required(VERSION 3.26 FATAL_ERROR)
project(winprefs)

include(GNUInstallDirs)

set(GCC_CLANG_SHARED_C_FLAGS "-fno-builtin;-std=gnu11")
set(GCC_CLANG_DEBUG_C_FLAGS
"-ggdb;\
-O0;\
-pedantic;\
-Wall;\
-Wdeprecated-declarations;\
-Wempty-body;\
-Werror;\
-Werror=conversion;\
-Werror=float-conversion;\
-Werror=implicit-function-declaration;\
-Werror=incompatible-pointer-types;\
-Werror=int-conversion;\
-Werror=return-type;\
-Werror=sign-conversion;\
-Wmissing-braces;\
-Wmissing-field-initializers;\
-Wno-missing-prototypes;\
-Wno-strict-prototypes;\
-Wno-trigraphs;\
-Wno-unknown-pragmas;\
-Wparentheses;\
-Wpointer-sign;\
-Wshadow;\
-Wsign-compare;\
-Wswitch;\
-Wuninitialized;\
-Wunknown-pragmas;\
-Wunreachable-code;\
-Wunused-function;\
-Wunused-label;\
-Wunused-parameter;\
-Wunused-value;\
-Wunused-variable")

add_executable(winprefs main.c)
if(CMAKE_COMPILER_IS_GNUCC OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
target_compile_options(
winprefs PRIVATE ${GCC_CLANG_SHARED_C_FLAGS}
$<$<CONFIG:Debug>:${GCC_CLANG_DEBUG_C_FLAGS}>)
endif()
install(TARGETS winprefs DESTINATION ${CMAKE_INSTALL_BINDIR})
Loading

0 comments on commit a7e83de

Please sign in to comment.