boostorg / boostorg/pfr

Can packed structures be supported?

Open
#93 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
1.5k
Forks
176
Avg merge
5d 21h
Merged PRs (30d)
1

Description

I noticed that packed structures are not supported, while it is not mentioned in documentation.

For example:

```c++
struct __attribute__ ((packed)) A
{
int x;
int z;
bool y;
};
```

The error message is following:

```
static_assert(sizeof(U) == sizeof(S), "====================> Boost.PFR: Member sequence does not indicate correct size for struct type! Maybe the user-provided type is not a SimpleAggregate?");
~~~~~~~~~~^~~~~~~~~~~~
```
Link: https://godbolt.org/z/Exo16Mods

However, the class should be an Aggregate, as

> _An aggregate is an array or a class (clause 9) with no user-declared constructors (12.1), no private or protected non-static data members (clause 11), no base classes (clause 10), and no virtual functions (10.3)._

Is there a technical obstacle on adding packed structures?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.