Search code examples
xcodefirefoxpluginsnpapi

STRINGZ_TO_NPVARIANT in xcode problem


have folowing code:

NPVariant type;
STRINGZ_TO_NPVARIANT("click", type);

and the xcode returns

"error: expected expression before 'uint32_t'"

anyone can give me a hand with this?


Solution

  • I ran into this as well. Based on this bug i found in the npapi project, i solved the problem by not using the macro, and using what it expands to instead, then applying what the patch shows. http://code.google.com/p/npapi-headers/issues/detail?id=3

    - NPString str = { _val, uint32_t(strlen(_val)) };

    + NPString str = { _val, (uint32_t)(strlen(_val)) };

    Basically, wrap uint32_t in parenthesis, then gcc will compile it.

    So the full replacement for the macro is

    NPVariant type;
    type.type = NPVariantType_String;
    NPString str = { "click", (uint32_t)(strlen("click")) };
    type.value.stringValue = str;