From fec86cbfcd6300a13fd146f4dab2d483720cc29b Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 15 Dec 2024 13:33:18 -0700 Subject: [PATCH] Enable clangd and fix some errors --- .vscode/c_cpp_properties.json | 50 ----------------------------------- .vscode/extensions.json | 8 +++++- .vscode/launch.json | 24 +++++++++-------- .vscode/settings.json | 14 +++++++--- include/DebugLog.h | 6 ++--- include/Light.h | 3 --- include/stl/stdarg.h | 6 ++--- include/types.h | 6 +++++ src/plugPikiColin/animMgr.cpp | 20 +++++++++++--- 9 files changed, 58 insertions(+), 79 deletions(-) delete mode 100644 .vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index c72a8b64..00000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/include", - "${workspaceFolder}/include/stl" - ], - "cStandard": "c99", - "cppStandard": "c++98", - "intelliSenseMode": "linux-clang-x86", - "compilerPath": "", - "configurationProvider": "ms-vscode.makefile-tools", - "forcedInclude": [ - ".vscode/warnings.h" - ] - }, - { - "name": "Win32", - "includePath": [ - "${workspaceFolder}/include", - "${workspaceFolder}/include/stl" - ], - "cStandard": "c99", - "cppStandard": "c++98", - "intelliSenseMode": "windows-msvc-x86", - "compilerPath": "", - "configurationProvider": "ms-vscode.makefile-tools", - "forcedInclude": [ - ".vscode/warnings.h" - ] - }, - { - "name": "Mac", - "includePath": [ - "${workspaceFolder}/include", - "${workspaceFolder}/include/stl" - ], - "cStandard": "c99", - "cppStandard": "c++98", - "intelliSenseMode": "macos-clang-x86", - "compilerPath": "", - "configurationProvider": "ms-vscode.makefile-tools", - "forcedInclude": [ - ".vscode/warnings.h" - ] - } - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index f1907448..33544369 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,12 @@ { "recommendations": [ + "llvm-vs-code-extensions.vscode-clangd", + "ms-python.black-formatter", + "ms-python.flake8", + ], + "unwantedRecommendations": [ + "ms-vscode.cmake-tools", + "ms-vscode.cpptools-extension-pack", "ms-vscode.cpptools", - "ms-vscode.makefile-tools" ] } diff --git a/.vscode/launch.json b/.vscode/launch.json index 12d360f5..6dc12130 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,14 +1,16 @@ { - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ + // Use Ctrl+Shift+B to run build tasks. + // Or "Run Build Task" in the Command Palette. + "version": "2.0.0", + "tasks": [ { - "name": "F5 Anything: Custom Command", - "type": "f5anything", - "request": "launch", - "command": "ninja" - } + "label": "ninja", + "type": "shell", + "command": "ninja", + "group": { + "kind": "build", + "isDefault": true + } + }, ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index b4d30d83..398c786b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,17 +1,23 @@ { "[c]": { "files.encoding": "utf8", - "editor.defaultFormatter": "ms-vscode.cpptools" + "editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd" }, "[cpp]": { "files.encoding": "utf8", - "editor.defaultFormatter": "ms-vscode.cpptools" + "editor.defaultFormatter": "llvm-vs-code-extensions.vscode-clangd" + }, + "[python]": { + "editor.defaultFormatter": "ms-python.black-formatter" }, "editor.tabSize": 4, "files.exclude": { "**/*.ctx": true }, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true, "files.associations": { + ".clangd": "yaml", "*.c.ctx": "c", "*.ctx": "cpp", "*.cp": "cpp", @@ -29,5 +35,7 @@ "rate.h": "c", "hw_regs.h": "c", "pikibgm.h": "c" - } + }, + // Disable C/C++ IntelliSense, use clangd instead + "C_Cpp.intelliSenseEngine": "disabled", } diff --git a/include/DebugLog.h b/include/DebugLog.h index 07db0300..1038b84e 100644 --- a/include/DebugLog.h +++ b/include/DebugLog.h @@ -41,8 +41,8 @@ #define PRINT(...) (__VA_ARGS__) #define ERROR(...) (__VA_ARGS__) #else -#define PRINT(fmt, ...) _Print(fmt, __VA_ARGS__) -#define ERROR(fmt, ...) _Error(fmt, __VA_ARGS__) +#define PRINT(fmt, ...) _Print(fmt __VA_OPT__(,) __VA_ARGS__) +#define ERROR(fmt, ...) _Error(fmt __VA_OPT__(,) __VA_ARGS__) #endif -#endif // _DEBUGLOG_H \ No newline at end of file +#endif // _DEBUGLOG_H diff --git a/include/Light.h b/include/Light.h index 97f3fc2d..b42ed4e7 100644 --- a/include/Light.h +++ b/include/Light.h @@ -146,9 +146,6 @@ struct LightGroup : public CoreNode { void ageDel(struct AgeServer&); virtual void genAge(class AgeServer&); - - void addLight(struct Vector3f&, f32); - void saveini(char*, struct RandomAccessStream&); #endif void loadini(CmdStream*); diff --git a/include/stl/stdarg.h b/include/stl/stdarg.h index dca1ddb2..d55682bc 100644 --- a/include/stl/stdarg.h +++ b/include/stl/stdarg.h @@ -31,15 +31,13 @@ void* __va_arg(va_list v_list, u8 type); #define va_arg(ap, t) (*((t*)__va_arg(ap, _var_arg_typeof(t)))) #define va_end(ap) (void)0 -#else -#ifdef __GNUC__ +#elif defined(__GNUC__) typedef __builtin_va_list va_list; #define va_start(v, l) __builtin_va_start(v, l) #define va_end(v) __builtin_va_end(v) #define va_arg(v, l) __builtin_va_arg(v, l) -#endif +#else typedef char* va_list; - #define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1)) #define va_start(ap, v) (ap = (va_list) & v + _INTSIZEOF(v)) #define va_arg(ap, t) (*(t*)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t))) diff --git a/include/types.h b/include/types.h index 76d9339b..4d1722f1 100644 --- a/include/types.h +++ b/include/types.h @@ -143,4 +143,10 @@ typedef unsigned long size_t; #define ASM #endif +// Disable some clangd warnings +#ifdef __clang__ +// Allow string literals to be converted to char* +#pragma clang diagnostic ignored "-Wc++11-compat-deprecated-writable-strings" +#endif + #endif // _TYPES_H diff --git a/src/plugPikiColin/animMgr.cpp b/src/plugPikiColin/animMgr.cpp index 7d2d61ee..f316dc15 100644 --- a/src/plugPikiColin/animMgr.cpp +++ b/src/plugPikiColin/animMgr.cpp @@ -1,7 +1,7 @@ #include "Animator.h" #include "Ayu.h" #include "Parameters.h" -#include "String.h" +#include "string.h" #include "stl/string.h" #include "Shape.h" #include "system.h" @@ -1186,18 +1186,30 @@ void Animator::changeContext(AnimContext* context) { mContext = context; } * Address: 80051460 * Size: 000008 */ -int Parm::size() { return sizeof(String); } +template <> +int Parm::size() +{ + return sizeof(String); +} /* * --INFO-- * Address: 80051468 * Size: 000008 */ -int Parm::size() { return sizeof(f32); } +template <> +int Parm::size() +{ + return sizeof(f32); +} /* * --INFO-- * Address: 80051470 * Size: 000008 */ -int Parm::size() { return sizeof(int); } +template <> +int Parm::size() +{ + return sizeof(int); +}