Re: Error in compliling AODB _ConnectionPtr

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Bruce Stemplewski (Bruce.Stemplewski_at_nospamstempsoft.com)
Date: 03/24/04


Date: Tue, 23 Mar 2004 19:20:38 -0500

Thanks for the explanation but I had already changed my code:

// Test.cpp : Defines the entry point for the console application.
//
#include <ole2.h>
#include <stdio.h>
#include <conio.h>

#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace
rename("EOF", "EndOfFile")

#include "stdafx.h"

int main(int argc, char* argv[])
{
 _ConnectionPtr pConnection = NULL;
 return 0;
}

and I still get a

 error C2065: '_ConnectionPtr' : undeclared identifier

Any ideas?

"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:Okop%233REEHA.548@TK2MSFTNGP10.phx.gbl...
It's very simple actually. The compiler ignores ALL input
before the #include file for hte precompiled header,
because it may affect the definitions in that header.
Conditional compilation should be a familiar concept
for any C and C++ developer. Since the precompiled
header (as it name says) is not compiled at this point,
the compiler cannot afford conflicting declarations
between what the header contains and what the subsequent
code may think. Hence the rule. Only put comments
before the precompiled header line.

-- 
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Kim Gräsman" <kim@mvps.org> wrote in message
news:OTdnNcQEEHA.1272@TK2MSFTNGP11.phx.gbl...
> Bruce,
>
> > Can you get it to compile?
>
> Sure, you just need to include stdafx.h first of all, before including or
> importing anything else - I should have been clearer on that in my
previous
> reply.
> Now, I patiently await Alexander's explanation of how it works, and why
the
> position of #include "stdafx.h" is important... :)
>
> Hope that helps,
> Kim
>
> > -----Original Message-----
> > From: Bruce E. Stemplewski
> > Sent: den 23 mars 2004 01:10
> > To: Kim Gräsman
> > Subject: Re: Error in compliling AODB _ConnectionPtr
> >
> > Sorry for not mentioning the version of C++.  I deserve 30 lashes :)
> >
> > I am using VC6
> >
> > I changed the code as follows and still get the complie error:
> >
> > // Test.cpp : Defines the entry point for the console application.
> > //
> > #include <ole2.h>
> > #include <stdio.h>
> > #include <conio.h>
> >
> > #import "C:\Program Files\Common
> > Files\System\ado\msado15.dll" no_namespace
> > rename("EOF", "EndOfFile")
> >
> >
> > #include "stdafx.h"
> >
> > int main(int argc, char* argv[])
> > {
> >  _ConnectionPtr    pConnection     = NULL;
> >  return 0;
> > }
> >
> > It is interesting that the complier does not complain if the
> > import path is
> > wrong.  I had it wrong at first anf the complier never complained.
> >
> > Can you get it to compile?
>
>


Relevant Pages

  • Re: Parameter Name Warning?
    ... there is more to those names than just what the compiler does with them. ... You know only what you get in the header. ... correct for me in the watch window. ... >> int main ...
    (microsoft.public.vc.language)
  • Re: Parameter Name Warning?
    ... the names on the declarations do not matter, it should perhaps give a warning regarding different names being used. ... > there is more to those names than just what the compiler does with them. ... > You know only what you get in the header. ... >>> int main ...
    (microsoft.public.vc.language)
  • Re: Micro$haft desperate! Buy Windoze 7, get (virtual) XP free!
    ... You would need to edit a few header files so they no longer use 'int' for the basic definitions. ... The defines are alternate names that can be controlled outside the compiler, ... Apple is still keeping Carbon up to date due to the OpenGL requirements. ...
    (comp.sys.mac.advocacy)
  • Re: Error in compliling AODB _ConnectionPtr
    ... The compiler ignores ALL input ... because it may affect the definitions in that header. ... before the precompiled header line. ... I had it wrong at first anf the complier never complained. ...
    (microsoft.public.vc.atl)
  • Re: Tool to determine which headers are needed/not_needed?
    ... Surely that's too simplistic - consider a header containing: ... #undef FOO ... int a=1; ... Then with the default options on a lot of compilers the compiler will *not* complain, it will just silently compiler the code with what is now undefined behaviour which may or may not work. ...
    (comp.lang.c)