Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8331175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:20:11+00:00 2026-06-09T02:20:11+00:00

I need to create a Firefox addon that calls C++ code. I did some

  • 0

I need to create a Firefox addon that calls C++ code. I did some research and found this tutorial to get me started: http://briankrausz.com/building-a-c-xpcom-component-in-windows/

I followed all the steps but got stuck in the part where I need to compile the code using VS. I’m using VS 2005.

To be more specific, I have a project that contains 2 header files (IMyComponent.h & MyComponent.h) as well 2 cpp files (MyComponent.cpp & MyComponentModule.cpp).

Each cpp file is configured to compile with no CLR support and without precompiled headers.

However, when I attempt to compile, I get 3 C2440 error messages that correspond to the following lines of code:

//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)

In the correspond header file I have the following code:

//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_

All the other code was generated using the xpidl.exe tool included with the Gecko SDK.

Can someone please give some hints?

PS: Here is the 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;
 };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:20:14+00:00Added an answer on June 9, 2026 at 2:20 am

    The first error is because you are trying to pass in a char * instead of the required type. This page: https://developer.mozilla.org/en/Adding_XPCOM_components_to_Mozilla_build_system

    at least mentions how to deal with the CID param:

    { "Friendly class description for people to read",
     YOUR_CLASS_CID,
     YOUR_CLASS_CONTRACTID,
     nsYourConcreteClassNameConstructor }
    

    and

    /* 2d96b3d0-c051-11d1-a827-0040959a28c9 */
    #define NS_WINDOW_CID \
    { 0x2d96b3d0, 0xc051, 0x11d1, \
    {0xa8, 0x27, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9}}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create/update/remove cookie for FireFox browser. This cookie is a client cookie,
I'd like to create an addon for Firefox that would enable me to search
I need create clone repository. but I do not know where can I get
I need to create plug-ins/add-ons for IE, firefox and chrome browsers for the following
I need to create a table in MySQL version 5.5 this table will have
I am using http://nithinbekal.com/2009/javascript-how-to-create-a-simple-countdown-timer/ But when I run it in firefox I get the
In Firefox this section of the code never seems to return true. Yet it
I need to create an auto-updater on clients computer that will automatically update a
I am writing a Firefox extension. Right now I need to create a local
I'm using xul to code a firefox extension, so I need to read/write from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.