How do I write to a struct like this?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: How do I write to a struct like this?

  1. #1
    Join Date
    Jan 2009

    How do I write to a struct like this?

    This is the struct that I need to write to, I can not change it as it's part of Firefox's api.
    typedef struct _NPVariant {
        NPVariantType type;
        union {
            bool boolValue;
            int32_t intValue;
            double doubleValue;
            NPString stringValue;
            NPObject *objectValue;
        } value;
    } NPVariant;
    It's been a long time since I've used unions and I don't remember how to write to it, and I think I've forgotten how to. I seemed to think that unionable items all had to be the same size (maybe that was just C.)

    But anyway, here my method is passed one of these structs via pointer from an external dll (which I also have no control over, it's the firefox flash plugin.)

    result -> type = NPVariantType_Int32;
    int32_t ii = ((Area*)PluginOwnerNPP) -> AbsTop.GetValuei();  //returns an int
    result -> value = ii;
    //result -> intValue = ii;

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Seattle, WA

    Re: How do I write to a struct like this?

    Try result->value.intValue = ii;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center