I thought of starting my Haiku development journey by tackling on EasyTasks lists issue #9460. There are two types of violations related to Standard Layout as I can see.
1 no virtual functions or virtual base classes
2 all non-static data members have the same access control
3 all non-static members of class type are standard-layout
4 any base classes are standard-layout
5 has no base classes of the same type as the first non-static data member.
6 meets one of these conditions:
* no non-static data member in the most-derived class and no more than one base class with non-static data members, or
* has no base classes with non-static data members
First one is of access control, which I was able to fix by creating a Static member function for calculating the offset of a private member variable.
Second one is more hard, which doesn’t allow any virtual functions in the base classes. We can bypass the warning by just replacing the macro with its actual value of
#define XFS_EXTENT_CRC_OFF ((size_t)(&((ExtentDataHeaderV5*)0)->crc))
instead of
#define XFS_EXTENT_CRC_OFF offsetof(ExtentDataHeaderV5, crc)
But this would be clearly unsafe.
I tried researching online about how we can avoid the usage of virtual functions, one of the options was using templates, which I wasn’t able to wrap my mind around.
Another was solution(?) can be to remove virtual keyword, again making it unsafe to use.
So, what is the correct way to move forward with this? Any help is appreciated.