Add // comment at the end of line to force clang-format
to NOT merge everything into single line. This:
becomes:
clang-format.exe --version.clang-format.exe --style=Microsoft --dump-config > .clang-format.Add header with above info to .clang-format, submit:
# clang-format version 18.1.8
# clang-format.exe --style=Microsoft --dump-config > .clang-format
---
Language: Cpp
# BasedOnStyle: Microsoft
...Single file:
Folder:
ls -Path . -Recurse -File -Include *.h,*.cpp `
| % { clang-format.exe -i --style=file:.clang-format $_.FullName }See /d1reportAllClassLayout – Dumping Object Memory Layout and VC++ 2013 class Layout Change and Wasted Space. For this code:
// main.cpp
struct MyBase
{
virtual ~MyBase() = default;
virtual void MyFoo() {};
int _data = -1;
};
struct MyDerived : MyBase
{
virtual void MyFoo() override {};
float _id = 0.0f;
};Running
cl /d1reportSingleClassLayoutMyDerived main.cpp
will dump:
class MyDerived size(12):
+---
0 | +--- (base class MyBase)
0 | | {vfptr}
4 | | _data
| +---
8 | _id
+---
MyDerived::$vftable@:
| &MyDerived_meta
| 0
0 | &MyDerived::{dtor}
1 | &MyDerived::MyFooNote there is also /d1reportAllClassLayout so you don’t
need to specify class name.