Hello all,

I'm trying to build my first XPCOM component by following the
tutorial: http://www.mozilla.org/projects/xpcom/book/cxc/html/newbookTOC.html
..and have overcome several issues related to obsolete functions and
the like. The following has got me pretty stuck, though, and any tips
would be appreciated.

Compiling this chunk of code (from the tutuorial) within
myEnumerator::GetNext:

    nsCOMPtr<nsIComponentManager> mCompMgr; 
    NS_GetComponentManager(getter_AddRefs(mCompMgr));

    nsISupportsCString* stringSupports; 
    mCompMgr->CreateInstance(kSupportsCStringCID,  
                             nsnull,  
                             NS_GET_IID(nsISupportsCString),  
                             (void**)&stringSupports); 

..results with this compile error:

WebLock.cpp(88) : error C2065: 'kSupportsCStringCID' : undeclared
identifier
 
Question 1) Is there a mechanism that details the history of obsoleted
code, and possibly what it was obsoleted by? It would be helpful to
find out what happened to kSupportsCStringCID. I have looked through
every repository exposed by LXR, and found nothing.



kSupportsCStringCID no longer exists in the code, so looking at some
other examples of CreateInstance(), I think this looks better:

    nsCOMPtr<nsISupportsString> stringSupports;
    mCompMgr->CreateInstance(NS_SUPPORTS_STRING_CID,  
                             nsnull,  
                             NS_GET_IID(nsISupportsString),  
                             getter_AddRefs(stringSupports)); 

..results with this compile error:

WebLock.cpp(88) : error C2660: 'CreateInstance' : function does not
take 0 parameters

..which looks like the NS_SUPPORTS_STRING_CID macro expanded into
something bad. From nsXPCOMCID.h (whose path DOES exist in the list of
include paths):

 98 #define NS_SUPPORTS_STRING_CID \
 99 { 0xacf8dc42, 0x4a25, 0x11d3, \
100 { 0x98, 0x90, 0x0, 0x60, 0x8, 0x96, 0x24, 0x22 } }

Question 2) Why does using NS_SUPPORTS_STRING_CID generate this error?
Have I constructed this call incorrectly?



Moving on to try another tack:

    nsISupportsCString* stringSupports; 
   mCompMgr->CreateInstanceByContractID(NS_SUPPORTS_STRING_CONTRACTID,
                                   nsnull,  
                                   NS_GET_IID(nsISupportsCString),  
                                   (void**)&stringSupports); 

..this compiles, but fails to link:

Linking...
   Creating library Debug/WebLock.lib and object Debug/WebLock.exp
embedstring.lib(nsDependentSubstring.obj) : fatal error LNK1103:
debugging information corrupt; recompile module Error executing
link.exe.

And now I'm trying to dig up what Visual Studio means by this,
although I suspect I've mixed string types incorrectly. The project is
configured to generate a DLL, so why it wants to build an EXE is
interesting.

Question 3) Recompiling didn't help. How do I remedy corrupt debugging
information?



And yet another tack:

nsCOMPtr<nsISupportsString> \
stringSupports(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));

..results with this compile error:

error C2065: 'do_CreateInstance' : undeclared identifier

Question 4) What does an object need in order to call
do_CreateInstance()? I have reviewed a dozen intances of its use, but
can't determine what the prerequisites or dependancies are to call it.



Thanks for you time,
Mike Muldoon
[EMAIL PROTECTED]

==========================
Build environment details:
Visual C++ 6.0
Mozilla 1.6b

Compile flags:
/nologo /MDd /W3 /Gm /GX- /ZI /Od /I

My includes:
C:\mozilla\dist\sdk\embedstring\include,
C:\mozilla\dist\sdk\xpcom\include,
C:\mozilla\dist\sdk\nspr\include, C:\mozilla\dist\sdkstring\include,
C:\mozilla\dist\include\xpcom <- added to find NSCom.h

My libpath:
C:\mozilla\dist\sdk\embedstring\bin,
C:\mozilla\dist\sdk\xpcom\bin,
C:\mozilla\dist\sdk\nspr\bin,
C:\mozilla\dist\sdk\string\bin
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to