<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/55783>55783</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang incompatibility with MSC pragma pack
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
russellw
</td>
</tr>
</table>
<pre>
This is a problem I ran into when trying to compile cpython on Windows. The following code fragment is excerpted from _tracemalloc.c; it is trying to define a struct that is packed to 4 byte alignment. (The actual version also contains an 8-byte element that depends on other things previously declared, but this version is enough to illustrate the problem.) On Windows, clang pretends to be Microsoft C, which is a sensible strategy, so it defines _MSC_VER and sees #pragma pack(push, 4) - but it does not actually understand that syntax! At least not in this context. It ends up saying 'error: declaration of anonymous struct must be a definition'.
typedef struct
#ifdef __GNUC__
__attribute__((packed))
#elif defined(_MSC_VER)
#pragma pack(push, 4)
#endif
{
unsigned int lineno;
} frame_t;
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx1VE1v2zAM_TX2haiR2HE-Dj606Tr00A3Y59GQLdrWJkuGRDf1vx-lJmk3YIGQxNQj-d6j5MbKpfo2KA-8BEzONhpHeAQnDChDFk4DGiC3KNMDP7Z2nJRGaKeFBmuA109lpD35DL4NCJ3V2p4CuLWSH53oRzQUyuNLi24ilBy1I9TkRIujYHybtUlxByrC3npJ7JRBpuXJzS0BDSIiJtH-5iqM2ECzECO06k1ok0GS7wMN0dIsNDyj84opCu0DdUNCGdZpYH8TE5HFBnaxssQJjfRBkqUBHUeZCLdz-Kzs7PXCkFYLhzLJj9DMIY_pXJoEicbO_RCYKa1npi24Cde6GJsl-QE-Xy0LZbggq-UeFJtzaoPwpFpnve0IjgFzGlQ7vE7Io_GKS8Fr8X4J-yxO0dkuD_XT12P948MX1ikZz5EkL6YwCBGtY4um2Q8hcRP43EQpoYBlrLF0do_1zkayOAqFokV-YQtfknwNtwQahaeIV-bVieAwvvAUHgmimnkCL-I4k3yHzlmXFLdnFwUF02zHNK1ZRjb4MueRnQsuiFdJKgA5P0tW98nq9vJ9oGVCBpyzrmEWq7oQr-uPn74f6_q6U9eCyClWixzN98GIeJTYhbDeVUCturOhvLu_WPoP6v-m_lXLSNW9BXZ31__An5nn2XOXcNtAcz9j-S68g9-HSzRiTddwKqtCHoqDSEmRxuoYj5Ay4W6yq43SihY4KRqAecM7lunsdDUQTZ7nkOQPvHqGzU3Gufyg9fPl54aP7C9kX_MH5f2MfFgfynK3L9KhkrJdr_Nuh-W6LA_FBnO5XRVbUe52-31bblMtGtS-Ssq7pLxPVZWv8nxVFqv1YbPNt5kUm67tVuv1NhfbUspks-IXgdJZaJxZ16euihyaufe8qZUn_7YpfLQML_XFzK8iV7nZe9T6lEa-VST7B4Zpn0o">