Clang-tidy: how to configure size_t, uintptr_t and pointers to 32-bits?

834 Views Asked by At

Clang-tidy is now part of the C/C++ plugin for VS Code. Earlier I were using the clang-tidy extension, and it was working fine. The issue is that clang-tidy now treats size_t, uintptr_t and all pointers as 64-bits, and issues warnings for 8/16/32-bit code (I'm working with microcontrollers). There are a lot of warnings that were not there earlier. Instead of disabling these checks, it would be better to configure clang-tidy appropriately.

Is there a way to tell clang-tidy the size of these datatypes?

1

There are 1 best solutions below

0
On

Adding this to settings.json seems to have solved the issue:

"C_Cpp.codeAnalysis.clangTidy.args": [
    "--extra-arg=--target=arm"
],

All warnings for initializing size_t with unsigned int values and casting pointers to/from unsigned int disappeared.