[Spice-commits] spice/vd_agent.h
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu May 31 16:26:07 UTC 2018
spice/vd_agent.h | 1 +
1 file changed, 1 insertion(+)
New commits:
commit ccda863268bde591b97a2991c7af2d29e74eeae7
Author: Frediano Ziglio <fziglio at redhat.com>
Date: Thu May 31 15:41:18 2018 +0100
vd_agent: Do not define structures without fields
According to C standard the size of a structure without fields is
not defined (see
https://stackoverflow.com/questions/21851930/size-of-empty-structure-in-c-and-c).
As we almost only use GCC currently these structures are of size 0.
This can became a problem if 2 sides talking a given protocol use
these structures.
To avoid such possible mismatch (for instance having one side C and
the other C++ which defines these structures as having 1 as size) add
an empty (0-size array) field.
Although a 0-size array is not considered also that portable we use
extensively this feature with different compilers never encountering
issues.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
Acked-by: Uri Lublin <uril at redhat.com>
diff --git a/spice/vd_agent.h b/spice/vd_agent.h
index 7109ede..dda7044 100644
--- a/spice/vd_agent.h
+++ b/spice/vd_agent.h
@@ -234,6 +234,7 @@ typedef struct SPICE_ATTR_PACKED VDAgentClipboardRelease {
uint8_t selection;
uint8_t __reserved[sizeof(uint32_t) - 1 * sizeof(uint8_t)];
#endif
+ uint8_t dummy_empty_field[0]; /* C/C++ compatibility */
} VDAgentClipboardRelease;
typedef struct SPICE_ATTR_PACKED VDAgentMaxClipboard {
More information about the Spice-commits
mailing list