-
November 13th, 2009, 10:43 AM
#1
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.
Code:
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.)
Code:
result -> type = NPVariantType_Int32;
int32_t ii = ((Area*)PluginOwnerNPP) -> AbsTop.GetValuei(); //returns an int
result -> value = ii;
//result -> intValue = ii;
-
November 13th, 2009, 10:48 AM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|