Search code examples
c++visual-studio-2008google-chrome-extensioncompiler-errorsnpapi

Newbie chrome-plugin developer needs help getting started with NPAPI


Although only having done a very little in C++ before I'm trying to compile the following chrome plugin so that I can see how it works and use that as a starting point to develop something similar: http://code.google.com/p/minimizetotray/source/browse/trunk/?r=17#trunk%2FDLL

So far I have taken the following steps: downloaded the source, opened it in MS Visual Studio Pro 2008, and obtained a few of SDKs and headerfiles it was asking for including the latest version of the NPAPI headers: http://npapi-sdk.googlecode.com/svn/trunk/headers/

Now I get the following errors when I try to compile and have no idea how to sort this.

    Compiling...
JSMethods.cpp
c:\documents and settings\dell customer\desktop\dll\jsmethods.cpp(92) : error C2039: 'UTF8length' : is not a member of '_NPString'
        c:\program files\microsoft visual studio 9.0\vc\include\plugin\npruntime.h(85) : see declaration of '_NPString'
c:\documents and settings\dell customer\desktop\dll\jsmethods.cpp(101) : error C2039: 'UTF8characters' : is not a member of '_NPString'
        c:\program files\microsoft visual studio 9.0\vc\include\plugin\npruntime.h(85) : see declaration of '_NPString'

Etc...

Apart from those two errors it all seems dandy, its not asking for missing includes or anything. Any help appreciated!


Solution

  • Unless I'm mistaken on the latest SDK the _NPString struct is defined as...

    typedef char NPUTF8;
    typedef struct _NPString {
        const NPUTF8 *UTF8Characters;
        uint32_t UTF8Length;
    } NPString;
    

    And in your code you are calling UTF8length instead of UTF8Length (uppercase L).