StructLayout
StructLayout copied to clipboard
Support Precompiled Headers & #pragma once
In my project, there are many precompiled headers such as this:
// common.h
#pragma once
class Common {
int field1;
char field2;
void *field3;
};
If common.h is precompiled, StructLayout's clang will fail to compile the header; clang ignores the #pragma once
directive on the primary source file.
To side-step this issue, the plugin could take an alternative approach:
Generate a new sourcefile, structlayout.cpp
:
#include "common.h" // this will respect #pragma once, if present
class StructLayoutTarget {
Common real_target;
};
The plugin would then invoke clang with the appropriate headers, pch's, defines, etc as it does now, but targeting structlayout.cpp
and its StructLayoutTarget class instead of targeting common.h
and its Common class.
Related: #40