# Tools

## compiler

* warnings are your friend
* clang from source
* cross platform different warnings
* old versions in distros

## clang-format

Automatic formatting of source code. A must have in my option. It doesn't matter what configuration you pick, the goal is for your complete code base to look as similar as possible.

```bash
# Formats all files with endings .h .hpp .cpp inplace (overrides).
find . -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format -i
```

## clang-tidy

Static analysis tool. Takes a lot of CPU to run, but finds a lot of valid issues.

## compiler-explorer

[https://godbolt.org](https://godbolt.org/)

Online compiler. Great for testing small code snippets. Does not currently have `JUCE` installed unfortunately.

## coverage

* gcc + gcov & lcov
* clang + llvm-profdata & llvm-cov

## Makefile/Scripts

I usually wrap all the common commands in a Makefile. Just to save some typing.

```
CONFIG ?= Release
BUILD_DIR ?= build
GENERATOR ?= Ninja

.PHONY: config
config:
    cmake -S. -B$(BUILD_DIR) -G$(GENERATOR) -DCMAKE_BUILD_TYPE=$(CONFIG)

.PHONY: build
build:
    cmake --build $(BUILD_DIR) --config $(CONFIG)

.PHONY: test
test:
    cd $(BUILD_DIR) && ctest -C $(CONFIG)

.PHONY: clean
clean:
    rm -rf $(BUILD_DIR)

.PHONY: format
format:
    find . -iname '*.h' -o -iname '*.hpp' -o -iname '*.cpp' | xargs clang-format -i
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tobanteaudio.gitbook.io/juce-cookbook/cpp/tools.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
