Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

We utilize the Linux Kernel Clang Formatter, which enforces Linux style syntax.

Within all C repositories, a GitHub Action is setup to check that all files have been formatted accordingly, and pull requests will not be able to merge unless it passes this request.

Fortunately, this formatter can be run by the user to automatically update their code to abide by these standards. The process for running this on a given file is as follows:

This process only works for NER applications, not for Embedded Base itself. If/when we get this running for embedded base, the process for running it on a file within that directory will be included below

In VScode:

  1. Open VScode from any NER C project

  2. Open file-->preferences-->settings

  3. Type clang in the settings search bar

  4. Change C_Cpp: Clang_format_fallback Style to none

  5. Change C_Cpp: Clang_format_style to file:${workspaceRoot}/Drivers/Embedded-Base/clang-format

Now, any time you save while in VScode, the file will automatically be linted through the formatter


In CLI:

Debian based Linux:

sudo apt-get install clang-format
clang-format -style=file -i path/to/your/file.c -assume-filename=path/to/your/.clang-format

Windows:

IDK tbh why are you using CLI if you are on windows anyway

(probably have to manually install clang for windows then update your path or something, y’all can figure it out, I think once it is installed correctly the command is the same as Linux and Mac)

Mac:

brew install clang-format
clang-format -style=file -i path/to/your/file.c -assume-filename=path/to/your/.clang-format

(obviously use whatever package manager you want)

Clang Ignore

If ever there is a block of code that needs an exception to this formatter, which does happen on occasion, you can encapsulate that code within these comments:

// clang-format off

...

// clang-format on
  • No labels