Skip to content

Commit

Permalink
IEE754 float flaws, more testing, fixups, string_view usage
Browse files Browse the repository at this point in the history
type sanitation got merged into llvm
  • Loading branch information
matu3ba committed Dec 20, 2024
1 parent 19a2d9b commit 77bf2fb
Show file tree
Hide file tree
Showing 23 changed files with 536 additions and 77 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ RequiresClausePosition: WithFollowing
RequiresExpressionIndentation: OuterScope
SpaceAfterTemplateKeyword: false
TabWidth: 2
UseTab: Never
4 changes: 2 additions & 2 deletions .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ CompileFlags:
# Add: [-std=c++14]
# Add: [-std=c++17]
# Add: [-std=c++20]
Add: [-std=c++23]
# Add: [-std=c++23]
# Add: [-std=c++26]
# Add: [-std=c++29]

# Add: [-std=c89]
# Add: [-std=c99]
Add: [-std=c99]
# Add: [-std=c11]
# Add: [-std=c17]
# Add: [-std=c23]
Expand Down
9 changes: 8 additions & 1 deletion .config/nvim/lua/my_lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
-- luacheck: globals vim
-- luacheck: no max line length

-- TODO simplify config based on 3f1d09bc94d02266d6fa588a2ccd1be1ca084cf7

-- lsp protocol
-- 1. file opened in editor -> editor supposed to inform server about changes to
-- document. Builtin neovim client do that. How exactly file stored on disk
Expand All @@ -22,6 +24,10 @@ local aucmd_lsp = vim.api.nvim_create_augroup('aucmds_lsp', { clear = true })

-- pip(x) install --upgrade ruff
-- npm install --save-dev --save-exact @biomejs/biome
-- git clone https://github.com/biomejs/biome
-- cargo install just
-- just install-tools
-- BIOME_VERSION=0.0.1 cargo build --bin biome --release

-- Manual (nvim-lsp name -- mason name):
-- 'bashls', -- 'bash-language-server'
Expand Down Expand Up @@ -103,7 +109,8 @@ end
-- traverses parent dir up to find yaml file .clangd
-- CompileFlags:
-- Add: [-std=c++20]
--lspconfig.biome.setup { capabilities = common_capabilities, on_attach = common_on_attach, }

lspconfig.biome.setup { capabilities = common_capabilities, on_attach = common_on_attach, }
lspconfig.clangd.setup { capabilities = common_capabilities, on_attach = common_on_attach, }
--lspconfig.gopls.setup { capabilities = common_capabilities, on_attach = common_on_attach, }
-- lspconfig.jedi_language_server.setup { capabilities = common_capabilities, on_attach = common_on_attach, }
Expand Down
3 changes: 2 additions & 1 deletion .config/nvim/lua/my_plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ return {
-- (((( explicit move: van)in)al)il)
-- cina/cila to modify fn args
-- example: 2cina to modify 'bb' in 'f(aa, bb)'
-- idea: get to prev selection not possible?
-- or leftwards: 2cila
{ 'echasnovski/mini.ai', config = function() require('mini.ai').setup {} end },

-- sa + motion/textobject + output id (to add), ie ( saiw) word -> (((word)))
Expand Down Expand Up @@ -241,6 +241,7 @@ return {
-- leap: enter repeats, tab reverses the motion
-- (unused default breaks mini.surround) s|S char1 char2 <space>? (<space>|<tab>)* label?
-- -|_ char1 char2 <space>? (<space>|<tab>)* label?
-- TODO figure out better keymap
{ 'ggandor/leap.nvim' }, -- repeat action not yet supported

-- Remote editing
Expand Down
2 changes: 2 additions & 0 deletions .gnupg/gpg-agent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ max-cache-ttl-ssh 7200
# pinentry-curses breaks like pinentry-tty within tmux/zellij
# Must use separate shell, ideally with tiling WM support, to fix this.
pinentry-program /usr/bin/pinentry-tty
# needed for neogit, should be default
# allow-loopback-pinentry
# nixos used /run/current-system/sw/bin/, but NixOS >=23.05 handles pinentry
# internally via systemd
#pinentry-program /run/current-system/sw/bin/pinentry-tty
Expand Down
4 changes: 3 additions & 1 deletion .gnupg/gpg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ no-comments
no-emit-version
# Disable banner
no-greeting
# Long hexidecimal key format
# Long hexadecimal key format
keyid-format 0xlong
# Display UID validity
list-options show-uid-validity
Expand All @@ -42,6 +42,8 @@ no-symkey-cache
use-agent
# Disable recipient key ID in messages
throw-keyids
# loopback mode is the default
# pinentry-mode loopback
# Default/trusted key ID to use (helpful with throw-keyids)
#default-key 0xFF3E7D88647EBCDB
#trusted-key 0xFF3E7D88647EBCDB
Expand Down
31 changes: 31 additions & 0 deletions example/cpp20_setup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
cmake_minimum_required(VERSION 2.6)
project(test)

# TODO distinguish profile clang|gcc|msvc dev|release
# TODO test if -g is implicit or what ReleaseDebug and Debug imply

add_executable(dev_gcc.exe)
target_sources(dev_gcc.exe PRIVATE use_gcc.cpp)
# more lightweight is -D_GLIBCXX_ASSERTIONS -DDEBUG
target_compile_options(dev_gcc.exe PRIVATE -std=c++20 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough -Werror -Wextra -Wpedantic -Wtrampolines -Wshadow -Wold-style-cast -Woverloaded-virtual -Wstrict-aliasing)

add_executable(rel_gcc.exe)
target_sources(rel_gcc.exe PRIVATE use_gcc.cpp)
target_compile_options(rel_gcc.exe PRIVATE -std=c++20 -Wall -Wformat -Wformat=2 -Wconversion -Wimplicit-fallthrough -Werror -Wextra -Wpedantic -Wtrampolines -Wshadow -Wold-style-cast -Woverloaded-virtual -Wstrict-aliasing)

add_executable(dev_clang.exe)
target_sources(dev_clang.exe PRIVATE use_gcc.cpp)
target_compile_options(dev_clang.exe PRIVATE -std=c++20 -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -Werror -Weverything -Wno-c++98-compat-pedantic -Wno-c++20-compat -Wno-unsafe-buffer-usage -Wno-switch-default)

add_executable(rel_clang.exe)
target_sources(rel_clang.exe PRIVATE use_gcc.cpp)
target_compile_options(rel_clang.exe PRIVATE -std=c++20 for production code -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero -Werror -Weverything -Wno-c++98-compat-pedantic -Wno-c++20-compat -Wno-unsafe-buffer-usage -Wno-switch-default)

# warning level
# cl /W4 /wd4146 /wd4245 /D_CRT_SECURE_NO_WARNINGS /Z7
# cl /Z7 /W4 /wd4146 /wd4245 /RTCcsu

# cmake -B build src/ -DCMAKE_BUILD_TYPE=Debug -GNinja && time cmake --build build
# watchexec -e hpp,cpp 'time cmake --build build && ./build/use_adjust.exe'
# cmake -B buildrel src/ -DCMAKE_BUILD_TYPE=ReleaseDebug -GNinja && time cmake --build buildrel
# watchexec -e hpp,cpp 'time cmake --build buildrel && ./buildrel/use_adjust.exe'
1 change: 1 addition & 0 deletions example/cpp20_setup/use_clang.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int main() { return 0; }
1 change: 1 addition & 0 deletions example/cpp20_setup/use_gcc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int main() { return 0; }
7 changes: 5 additions & 2 deletions example/portable_printf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Tested with
//! zig cc -std=c99 -Werror -Weverything -Wno-unsafe-buffer-usage -Wno-declaration-after-statement -Wno-switch-default ./templates/common.c
//! zig cc -std=c23 -Werror -Weverything -Wno-unsafe-buffer-usage -Wno-declaration-after-statement -Wno-switch-default -Wno-c++98-compat -Wno-pre-c11-compat -Wno-pre-c23-compat ./templates/common.c
//! zig cc -std=c99 -Werror -Weverything -Wno-unsafe-buffer-usage -Wno-declaration-after-statement -Wno-switch-default ./example/portable_printf.c -o portable_printf99.exe && ./portable_printf99.exe
//! zig cc -std=c23 -Werror -Weverything -Wno-unsafe-buffer-usage -Wno-declaration-after-statement -Wno-switch-default -Wno-c++98-compat -Wno-pre-c11-compat -Wno-pre-c23-compat ./example/portable_printf.c -o portable_printf23.exe && ./portable_printf23.exe
#include <inttypes.h> // PRIu64
#include <stddef.h> // ptrdiff_t
#include <stdio.h> // printf
Expand All @@ -9,6 +9,9 @@
// intmax_t and uintmax_t

// For embedded C, use https://github.com/mpaland/printf or https://github.com/eyalroz/printf
// For C99 there is no type safe printing possible without extensions. Use compiler options and clangd.
// For C11 use idea adjust https://github.com/nickelca/generic-print
// For C23 use https://github.com/nickelca/generic-print

int main(void) {
// https://en.cppreference.com/w/cpp/types/integer
Expand Down
Loading

0 comments on commit 77bf2fb

Please sign in to comment.