quiklearner

We have an application, with all of the components written in VB. It is an "Multi-Thread" ActiveX EXE that instantiates components from dlls on seperate threads. The type of objects instantiated are actually derived from another VB DLL where an interface is defined and these instantiated objects use the Implements keyword. I am attempting to rewrite the main application in a C++ console app. (I have all of the threading stuff done and am down to working with each VB component)

I have used the #import statement on the interface dll. It doesn't seem to matter what I do, I can't get the app to compile when i attempt to define a _ClassPtr object even though intellisense sees everything fine. Whether or not I have no_namespace or not, if I include the namespace it says: 2653:is not a class or namespace name, and it always gives me a 2065:undeclared identifier for the _ClassPtr. Relevent code:

#import "C:\Documents and Settings\Owner\Desktop\Interface\IAdjService.dll" \ no_namespace

and

IAdjService::_IServicePtr pServ;

Any ideas



Re: Visual C++ Language Intellisense sees it but the compiler doesn't

crescens2k

Need more information.

The errors that the compiler actually outputs and the actual code.

But you have to remember that VB 2005 has a root namespace which all the sub namespaces are put in, maybe you are being affected by this.






Re: Visual C++ Language Intellisense sees it but the compiler doesn't

Sdi

Check the .TLH and .TLI files generated from the #import directive; the correct type names will be there.



Re: Visual C++ Language Intellisense sees it but the compiler doesn't

quiklearner

vc++/vb 6.0 sp6

#import "C:\Documents and Settings\Owner\Desktop\AdjSvc\Interface\IAdjService.dll" no_namespace

// and

_IServicePtr pServ; // inside of a function

produces:

C:\Documents and Settings\Owner\Desktop\AdjSvc\WorkingAdjSvc\AdjSrvc\AdjSrvc.cpp(33) : error C2065: '_IServicePtr' : undeclared identifier
C:\Documents and Settings\Owner\Desktop\AdjSvc\WorkingAdjSvc\AdjSrvc\AdjSrvc.cpp(33) : error C2146: syntax error : missing ';' before identifier 'pServ'
C:\Documents and Settings\Owner\Desktop\AdjSvc\WorkingAdjSvc\AdjSrvc\AdjSrvc.cpp(33) : error C2065: 'pServ' : undeclared identifier

The TLI and/or the TLH show the IService class implementable as _IServicePtr. (or IAdjService::_IServicePtr with the namespace) I believe the TLI/TLHs are where intellisense gets it's information from. Seems like the IDE has no problems but the compiler just isn't seeing it. Also, at one point I had tried to add a .h file and included it from my .cpp file, but the compiler didn't see the enumeration/struct defs I had put in it. I ended up putting the them directly in the cpp file.





Re: Visual C++ Language Intellisense sees it but the compiler doesn't

Sdi

Possibly-dumb question: you are #include'ing the .TLH in the .CPP that uses it, right





Re: Visual C++ Language Intellisense sees it but the compiler doesn't

quiklearner

I thought the compiler generated the TLI and TLH at the #import, but also internally swapped the #import out with a #include



Re: Visual C++ Language Intellisense sees it but the compiler doesn't

Sdi

It does, but that imputed #include only appears in the file containing the #import directive; if the generated header is needed in other source files, it has to be #include'd there too.





Re: Visual C++ Language Intellisense sees it but the compiler doesn't

quiklearner

Yes the #import exists in the cpp i have the compiler errors in



Re: Visual C++ Language Intellisense sees it but the compiler doesn't

Sdi

What happens if you replace the #import with an #include of the .TLH (You'll get link errors without the .TLI, but right now we're concerned with the identifiers that the compiler can't seem to resolve).





Re: Visual C++ Language Intellisense sees it but the compiler doesn't

quiklearner

Same exact thing.. Could this be related to why I wasn't able to #include stuff before What could cause that



Re: Visual C++ Language Intellisense sees it but the compiler doesn't

Sdi

Sorry, I guess I missed a previous discussion of "wasn't able to #include stuff"; what's that about

If it doesn't compile with the .TLH, are we sure that there isn't a namespace or some other scope in the .TLH If the identifier in the .TLH is identical to the one in the .CPP, there has to be an issue with qualifiers or scoping.





Re: Visual C++ Language Intellisense sees it but the compiler doesn't

quiklearner

re-read the end of the response that starts with "vc++/vb 6.0 sp6"



Re: Visual C++ Language Intellisense sees it but the compiler doesn't

Sdi

Ah. Sounds like the same issue as with #include'ing the .TLH Since I don't have the .TLH and .CPP, I can't see the problem from here, but I still think it's either an identifier mismatch or a scoping problem.



Re: Visual C++ Language Intellisense sees it but the compiler doesn't

quiklearner

Ok easy fix, I can't believe I didn't think of it for so long.. It was the order of the #includes in relation to the #import.. Thanks for your help though Sdi..