Re: XPCOM from C, not C++

Boris Zbarsky <[email protected]> Thu, 18 Jan 2007 11:26:35 -0600
Newsgroups gmane.comp.mozilla.documentation
Message-ID <[email protected]>
Peter Parente wrote:
> Is it possible to use XPCOM from straight C code?

As I understand it, if someone creates C bindings for it.  You'd need some 
C-to-C++ bridge, since the XPCOM objects are C++ objects and in particular use 
virtual functions...

Note that either the page at 
http://developer.mozilla.org/en/docs/XPCOM:Language_Bindings is wrong or I 
understand incorrectly.  ;)

If it's possible to just make calls on XPCOM objects from C, then your example 
will work if you just get rid of the nsCOMPtr stuff and replace it with manual 
reference-counting.  You might also need to change the NS_GET_IID thing to 
something else; not sure.

-Boris