This is just a test c++ repo. Go ahead and break it.
include | Add SeparateDefinitionBlocks to .clang-format | 2025-01-21 13:07:32 |
---|---|---|
my_lib | Add SeparateDefinitionBlocks to .clang-format | 2025-01-21 13:07:32 |
product | Add SeparateDefinitionBlocks to .clang-format | 2025-01-21 13:07:32 |
.clang-format | Add SeparateDefinitionBlocks to .clang-format | 2025-01-21 13:07:32 |
.gitignore | Add two implementations of round_up_to_next_power_of_two | 2019-01-24 20:54:16 |
Makefile | Minor edit to Makefile to support explicit 'all' target. | 2021-11-03 23:21:53 |
README.md | Use grep instead of awk to choose files to format. | 2024-12-22 14:47:05 |
build | first commit | 2015-11-07 22:13:58 |
make_path_helper | first commit | 2015-11-07 22:13:58 |
makecscope.sh | Prune .git directory in find command. | 2022-07-03 14:16:49 |
maketags.sh | Remove declaration tags. Better support vim code block navigation. | 2022-04-08 11:46:34 |
testcode.code-workspace | Add a Workspace for MS Code | 2021-05-29 21:37:33 |
testcode.sublime-project | first commit | 2015-11-07 22:13:58 |
unused.h | Add .clang-format | 2023-08-12 23:24:26 |
This is just a test project. You can do anything here, test g++, make, cmake, git, cscope, and IDE projects.
You can get a copy of this project by clicking on the ZIP or TAR buttons near the top right of the GitList web page.
You can clone from the origin with:
git clone ssh://USERNAME@dlma.com/~/git/testcode.git
Create two panes in tmux, run vim in one, and run entr in the other. You probably
only need the git ls-files
for entr
, but I provide a bash command group with
find
here so I can easily copy and change it as needed.
{ git ls-files && find . -type f -regex '.*\.\(cfg\|local\)'; } | \
entr -c sh -c 'ctags -R *; make -j$(nproc) && \
valgrind -q --leak-check=yes --show-leak-kinds=all product/testcode'
find
could also have been find . -type f \( -name \*.cfg -or -name \*.local \)
.
To compile with debug info and run in gdb:
... | entr -c sh -c 'ctags -R *; make debug -j$(nproc) && gdb product/testcode'
Tip: In vim you can grep and use the QuickFix window with commands like...
:grep -rI --exclude=tags --exclude=cscope.* --exclude-dir=obj searchterm .
:cw
See this QuickFix tip for sorting results by filename.
This entr command is handy when composing interview questions without a Makefile:
ls -1 *.h *.cpp | entr sh -c 'g++ -Wall -std=c++17 -pthread *.cpp && \
valgrind -q --leak-check=yes --show-leak-kinds=all ./a.out'
Once you've got the Remote -WSL extension for WSL, you can invoke Code from the WSL side.
code .
Or, if it's not in your path, something like...
/mnt/c/Users/$USER/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code .
Look for the presence of their project files. They should work normally.
Use clang-format. Install the distro's version with:
sudo apt install clang-format
Or install a newer one with:
pipx install clang-format
And move $HOME/.local/bin ahead of /usr/bin in your $PATH.
Then, after making your edits, use the vim integration or manually format in one of a couple of ways:
NOTE git-clang-format only formats your changes. Often it's better to always format the whole document.
git-clang-format
is installed with clang-format and will format staged files
into the unstaged area. Use it like this:
git clang-format
, and it'll leave unstaged formatting changes.git difftool
and accept the desired changes or unstage.The following formats the staged files, not only your staged changes:
git status --porcelain | \
grep -Po '^[MTARC]..\K.+\.[ch](pp)?"?$' | \
xargs clang-format -i
Or a similar approach but it'll also overwrite your unstaged changes too:
git ls-files -m | \
grep -E ".[ch](pp)?$" | tr "\n" "\0" | \
xargs -0 clang-format -i
Yes.