I am maintaining a C6727-based product which involves streaming data from a host PC to the DSP memory space. This data may include arbitrarily complex C/C++ data structures. I must guarantee that the data structures which are generated and initialized on the host PC match the data structures which the compiled C6727 instructions expect to receive - for example, all data member alignment must match across the two platforms. Possible host-side compilers include GCC, LLVM/clang, and MSVC.
I know that the CCS compiler uses 8-byte alignment, so we have some wrapping code around the definitions of all data structures which may be transmitted to the DSP. This wrapping code sets #pragma pack(push,8) / #pragma pack(pop) around each structure. This seems to work just fine for ensuring 8-byte alignment of the structures.
In addition to the 8-byte packing, this wrapping code also includes #pragma ms_struct on / #pragma ms_struct off when using GCC or LLVM/clang. Here is some background on that pragma according to the GCC documentation:
"If packed is used on a structure, or if bit-fields are used it may be that the Microsoft ABI packs them differently than GCC normally packs them."
https://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
Since I inherited this code, I have to assume that the reason this pragma is used is that the CCS compiler follows the same packing rules as MSVC.
As of Xcode 6, however, clang has added a warning about use of ms_struct with data structures that include base structures or virtual functions:
#pragma ms_struct can not be used with dynamic classes or structures
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20140224/100153.html
Apparently, although this warning was only recently added, GCC and LLVM/clang do not, and never have, guaranteed that data alignment for data structures that include either base structures or virtual functions will be equivalent with MSVC, even when using the ms_struct pragma.
My questions are:
1) Am I correct that the CCS compiler follows the same alignment rules as MSVC with #pragma pack(8)?
2) Does the CCS compiler similarly guarantee identical data alignment with MSVC for data structures with base structures and/or virtual functions?
3) Is there any way to guarantee that such structures will be compatible (i.e. identical) between LLVM/clang and the CCS compiler?