https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120498

--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #11)
> So you can't use designated initializers with that type in C++.

This is true for *most* POSIX structs, because POSIX does not guarantee the
order of members, or whether there are other non-standard members.

e.g. for struct sigaction it only says:

  The structure sigaction, used to describe an action to be taken, is defined
in the
  <signal.h> header to include at least the following members:
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

So there can be additional unspecified members, and the order of members is not
specified.

Since C++ designated initializers require all members to be explicitly
initialized in the correct order, you can't do that in portable code.

POSIX also says:

  The storage occupied by sa_handler and sa_sigaction may overlap, and a
conforming
  application shall not use both simultaneously.

So they might be union members, or they might be separate members. For C++
designated initializers, you need to know which it is.

Reply via email to