David Blume's GitList
Repositories
testcode.git
Code
Commits
Branches
Tags
Search
Tree:
6397100
Branches
Tags
c++11
main
start
testcode.git
README.md
Added instructions for newer clang-format
dblume
commited
6397100
at 2023-08-13 16:53:29
README.md
Blame
History
Raw
# testcode This is just a test project. You can do anything here, test g++, make, cmake, git, cscope, and IDE projects. ## Getting the project You can get a copy of this project by clicking on the [ZIP](https://git.dlma.com/testcode.git/zipball/main) or [TAR](https://git.dlma.com/testcode.git/tarball/main) 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 ## IDEs ### tmux vim entr 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](https://git.dlma.com/dotfiles.git/commit/0cb566c53caf931c8b3f423dcfded4660b220cbb). #### entr One-Liner for When no Makefile [This entr command is handy](https://twitter.com/dblume/status/1421011043489255424) 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' ### Visual Studio Code and WSL2 Once you've got the [Remote -WSL extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl) 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 . ### Formatting Use clang-format. Install the distro's version with: sudo apt install clang-format Or install a newer one (replace 17 with whatever's current now) with: wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 17 sudo apt install clang-format-17 Then, after making your edits, use the [vim integration](https://clang.llvm.org/docs/ClangFormat.html#vim-integration) or manually format with: git status --porcelain | \ awk 'match($1, "M|A") && match($2, "(c|h)(pp)?$"){print $2}' | \ xargs clang-format-17 -style=file -i Or, shorter but less comprehensive: git ls-files -m | egrep ".(c|h)(pp)?$" | xargs clang-format-17 -style=file -i ### Other IDEs Look for the presence of their project files. They should work normally. ## Current Features * Multiple directories for testing build systems and IDEs * "make" essentially works. ## Is it any good? [Yes](https://news.ycombinator.com/item?id=3067434). ## To Do * Compare make vs. cmake vs. autotools * Experiment with ctags generation