From 1489f4c3a0bd6c850f3a1a75551fd50cd56d91d2 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sun, 9 Aug 2026 16:48:46 +0200 Subject: [PATCH] editor: clangd and cmake work from a committed vscode workspace The three files libavr's consumers carry, in the leaf-application shape: nothing vendors this repo, so .clangd names the one build tree an editor should read (build/atmega328p-generated) beside the stand-ins clang needs for GCC's AVR dialect; .vscode/settings.json passes --query-driver and names the toolchain prefix for the window that opens this folder. The libavr pin advances to the editor-audit fixes. One residue stays red and is the documented frontend divergence, not a defect: thermistor.hpp's consteval Beta-equation table folds __builtin_log under GCC, which clang refuses to fold in a constant expression -- the same class as libavr's breathe example and its __builtin_cos. Co-Authored-By: Claude Fable 5 --- .clangd | 30 ++++++++++++++++++++++++++++++ .vscode/extensions.json | 6 ++++++ .vscode/settings.json | 34 ++++++++++++++++++++++++++++++++++ libavr | 2 +- 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .clangd create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..af27531 --- /dev/null +++ b/.clangd @@ -0,0 +1,30 @@ +CompileFlags: + # Named here rather than in the editor's settings because nothing vendors + # this repo: the one build tree is the one an editor should read. + CompilationDatabase: build/atmega328p-generated + Add: + # clang has no 24-bit integer and GCC's are keywords, not macros, so the + # editor needs a stand-in for avr::uint24_t. The next width up is the only + # one available — clang rejects _BitInt(24) on this target. + - -D__uint24=unsigned long + - -D__int24=long + # clangd forwards the driver's system includes but not its own header + # directory, so resolves to avr-libc's, which still gates the + # limit and constant macros on the C++98 opt-in. + - -D__STDC_LIMIT_MACROS + - -D__STDC_CONSTANT_MACROS + # isr::emit spells a vector number into [[gnu::signal(N)]], which clang + # rejects rather than ignores — enough of them in one TU to reach the + # default limit of 19 inside the headers and truncate the parse. + - -ferror-limit=0 + Remove: + # The build promotes warnings for the compiler that has to be right about + # them; in the editor the flag paints a second frontend's opinions in the + # colour reserved for things that do not compile. + - -Werror +Diagnostics: + Suppress: + # clang's AVR `signal` attribute takes no arguments and it knows none of + # progmem, naked or OS_main. A misspelling is what the build is for. + - attribute_wrong_number_arguments + - unknown-attributes diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..b8c5a5b --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "llvm-vs-code-extensions.vscode-clangd", + "ms-vscode.cmake-tools" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b129e62 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,34 @@ +{ + // clangd is the language server; the cpptools engine would parse every file + // a second time and disagree, since nothing tells it about a cross + // compiler. Which database to read is in .clangd. + "C_Cpp.intelliSenseEngine": "disabled", + + // --query-driver lets clangd ask the cross compiler for its own system + // includes and target; without it every standard header is missing. + "clangd.arguments": [ + "--query-driver=**avr-g++*", + "--header-insertion=never" + ], + + // The presets are the build interface; the toolchain file inside the + // libavr submodule is the one place the compiler is chosen. The submodule + // carries no local/toolchain for it to discover, so the prefix is named + // here, for the window that opens this folder. + "cmake.useCMakePresets": "always", + "cmake.environment": { + "LIBAVR_TOOLCHAIN": "D:/dev/libavr/local/toolchain/avr-gcc-16.1.0-mingw" + }, + "cmake.configureOnOpen": true, + "cmake.options.statusBarVisibility": "compact", + + "files.watcherExclude": { + "**/build/**": true, + "**/libavr/**": true + }, + + "files.associations": { + ".clangd": "yaml", + ".clang-format": "yaml" + } +} diff --git a/libavr b/libavr index 26109e1..07a0c40 160000 --- a/libavr +++ b/libavr @@ -1 +1 @@ -Subproject commit 26109e172be4ab5cf17c9efb8c7e36d1f1caa485 +Subproject commit 07a0c4023564eb4bd72e33ff84399105390716e9