[Spice-devel] messages.h unable to be used in VC++

Alon Levy alevy at redhat.com
Wed Apr 18 02:09:45 PDT 2012


On Tue, Apr 17, 2012 at 12:49:11PM -0500, Aric Stewart wrote:
> Yeah, i am wondering a bit about this also.
> 
> I know under c++ sizeof and empty struct will return 1
> gnu c will return 0
> msvc++ fails.
> 
> adding a uint8_t padding member will make it always return 1.  I am not sure
> if that is going to be an issue.
> 
> I am totally not an expert on the wire protocol, which is the motivation for
> this question.
> 
> We may need to go through and change the parse_SpiceMsgEmpty implementation?
> 
> -aric
> 
> On 4/17/12 12:41 PM, Brian Vetter wrote:
> >Not sure if this applies since I'm looking at the spice-gtk 0.11 source,
> >but the generated_demarshallers.c code includes a function
> >parse_SpiceMsgEmpty. Within it it uses "sizeof(SpiceMsgEmpty)" and some
> >pointer/allocator math for demarshalling a SpiceEmptyMsg. I'm no expert
> >here, but I would think that might cause an issue for the wire protocol.

I've looked at it, this doesn't affect the wire protocol at all. It's
used for the demarshalling, since the message doesn't contain any fields
nothing is copied from the wire to the newly allocated struct, the only
difference is that now a 1 byte struct is allocated - but since malloc
has to return a unique address even when invoked as malloc(0) I think
this doesn't change anything in practice.

> >
> >Brian
> >
> >On Apr 17, 2012, at 12:10 PM, spice-devel-request at lists.freedesktop.org
> ><mailto:spice-devel-request at lists.freedesktop.org> wrote:
> >
> >>On Tue, Apr 17, 2012 at 08:15:22AM -0500, Aric Stewart wrote:
> >>>Hello all,
> >>>
> >>>Working away at making the current tip of spice build the win32 client. I
> >>>have run into another problem.
> >>>
> >>>Since the last working win32 cllient build the code generated by
> >>>spice_codegen.py has shifted from CPP files to C files. The generated
> >>>files
> >>>include messages.h.
> >>>
> >>>Inside messages.h there is a structure SpiceMsgEmpty which is empty.
> >>>Empty
> >>>structures in C have 0 bytes and are not defined in the spec. VC++ treats
> >>>this as a hard error (C2015) and so refuses to compile the code. gcc does
> >>>not treat this as an error, so mingw and gcc builds have not noticed
> >>>this.
> >>>
> >>>How do we want to handle this.
> >>>
> >>>We could put a single padding member in that structure that would allow
> >>>the compile to work, but it would make the structure size expand to a
> >>>byte
> >>>and have an unused member.
> >>
> >>Looks like this should just work. Maybe you could try this?
> >>
> >>>
> >>>If I have the VC++ build path continue to generate cpp files instead of C
> >>>files then there are issues with the bindings defined in
> >>>client_demarshallers.h and the SPICE_BEGIN_DECLS lines will have to be
> >>>#ifdefed out for win32.
> >>>
> >>>Thanks!
> >>>-aric
> >>>_______________________________________________
> >>>Spice-devel mailing list
> >>>Spice-devel at lists.freedesktop.org
> >>><mailto:Spice-devel at lists.freedesktop.org>
> >>>http://lists.freedesktop.org/mailman/listinfo/spice-devel
> >>
> >
> >
> >
> >_______________________________________________
> >Spice-devel mailing list
> >Spice-devel at lists.freedesktop.org
> >http://lists.freedesktop.org/mailman/listinfo/spice-devel
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list