Search code examples
pluginsnpapi

NPAPI BasicPlugin in C++


This basic npapi plugin is written in C. I'm developing on Mac and using xcode the project compiles and works. But I would like it to be in C++, what should I do to convert this to a C++ project? Or is there a similar example available in C++?

Thanks in advance!


Solution

    1. Rename BasicPlugin.c to BasicPlugin.cc (or .cpp, or whatever C++ suffix you like). .Do this from the Xcode UI, so the project will be updated automatically.

    There is no step 2. Once the file is being treated as a C++ file by the compiler, you can add all all the C++ you want. C++ is a superset of C, so all the existing code should work as-is.