C++ コードを呼び出す Firefox アドオンを作成する必要があります。私はいくつかの調査を行い、このチュートリアルを見つけて始めました: http://briankrausz.com/building-ac-xpcom-component-in-windows/
すべての手順に従いましたが、VS を使用してコードをコンパイルする必要がある部分で行き詰まりました。私はVS2005を使用しています。
具体的には、2 つのヘッダー ファイル ( IMyComponent.h& MyComponent.h) と 2 つの cpp ファイル ( MyComponent.cpp& MyComponentModule.cpp) を含むプロジェクトがあります。
各 cpp ファイルは、CLR をサポートせず、プリコンパイル済みヘッダーなしでコンパイルするように構成されています。
ただし、コンパイルしようとすると、次のコード行に対応する 3 つの C2440 エラー メッセージが表示されます。
//MyComponentModule.cpp
#include "nsIGenericFactory.h"
#include "MyComponent.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(MyComponent)
static nsModuleComponentInfo components[] =
{
    {
      MY_COMPONENT_CLASSNAME,
      MY_COMPONENT_CID,          //'initializing': cannot convert from const char[37]    to PRUint32
      MY_COMPONENT_CONTRACTID, //'initializing': cannot convert from const char[39] to    PRUint16
      MyComponentConstructor, //'initializing': cannot convert from nsresult (__stdcall *)(nsISupports *, const nsIID &, void **) to PRUint16
   }
};
NS_IMPL_NSGETMODULE("MyComponentsModule", components)
対応するヘッダー ファイルには、次のコードがあります。
//MyComponent.h
#ifndef _MY_COMPONENT_H_
#define _MY_COMPONENT_H_
#include "IMyComponent.h"
#define MY_COMPONENT_CONTRACTID "@example.com/XPCOMSample/MyComponent;1"
#define MY_COMPONENT_CLASSNAME "A Simple XPCOM Sample"
#define MY_COMPONENT_CID "4c6f45e0-6366-4c69-Ab68-bb3c75cdada3"
class MyComponent : public IMyComponent
{
public:
 NS_DECL_ISUPPORTS
 NS_DECL_IMYCOMPONENT
 MyComponent();
private:
  ~MyComponent();
protected:
  /* additional members */
};
#endif //_MY_COMPONENT_H_
他のすべてのコードは、Gecko SDK に含まれている xpidl.exe ツールを使用して生成されました。
誰かヒントを教えてください。
PS: nsModuleComponentInfo は次のとおりです。
 struct nsModuleComponentInfo {
 const char*                                 mDescription;
 nsCID                                       mCID;
 const char*                                 mContractID;
 NSConstructorProcPtr                        mConstructor;
 NSRegisterSelfProcPtr                       mRegisterSelfProc;
 NSUnregisterSelfProcPtr                     mUnregisterSelfProc;
 NSFactoryDestructorProcPtr                  mFactoryDestructor;
 NSGetInterfacesProcPtr                      mGetInterfacesProc;
 NSGetLanguageHelperProcPtr                  mGetLanguageHelperProc;
 nsIClassInfo **                             mClassInfoGlobal;
 PRUint32                                    mFlags;
 };