VC6->VC9 Errors

  • Thread starter Thread starter Anna Smidt
  • Start date Start date
A

Anna Smidt

Hello!
Sven told me I could come here if I have problems compiling. I am
wondering if I can also post translation errors from VC6 to VC9 here.
Thanks.
Anna
 
Hi Anna,
Sven told me I could come here if I have problems compiling. I am
wondering if I can also post translation errors from VC6 to VC9 here.

Just try and ask.

As VC6 is "only" native C++ I expect that your converted projects are
also native VC++ projects. Whenever you see a .dotnet. in the newsgroup
name it is more or less managed code related.

For native VC++ questions you might want to try this:

microsoft.public.vc.language

There are also more specific ones e.g. atl, mfc and stl.

This helps in bringing the right questioners and answerers together.
 
Thanks. :-*

I will start bit by bit. It's not hundreds of errors, only 15:

Nr. 1:

typedef struct _EXCEPTION_POINTERS {
PEXCEPTION_RECORD ExceptionRecord;
PCONTEXT ContextRecord;
} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;

Error 2 error C2061: syntax error : identifier 'PCONTEXT'
C:\Programs\Windows Mobile 5.0 SDK R2\PocketPC\Include\Armv4i\winnt.h
2976 stasm

About this error:
Apart from the error, I was wondering why I have to include winnt.h from
such a specific Include lib. I would have thought it's under the PSDK.

Anna
 
typedef struct _EXCEPTION_POINTERS {
PEXCEPTION_RECORD ExceptionRecord;
PCONTEXT ContextRecord;
} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;

Error 2 error C2061: syntax error : identifier 'PCONTEXT'

....Is #include <windows.h> not sufficient?

Giovanni
 
I am confused...
When I tried to compile it again, it said

Error 1 error C2146: syntax error : missing ';' before identifier
'ContextRecord' C:\Programs\Windows Mobile 5.0 SDK
R2\PocketPC\Include\Armv4i\winnt.h 2976 stasm

Yes, there is #include <windows.h>, so I don't really understand your
question if #include <windows.h> is enough.

Sorry, I am still really confused about the whole include thing.
Anna
 
Hi Anna,
typedef struct _EXCEPTION_POINTERS {
PEXCEPTION_RECORD ExceptionRecord;
PCONTEXT ContextRecord;
} EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;

Error 2 error C2061: syntax error : identifier 'PCONTEXT'
C:\Programs\Windows Mobile 5.0 SDK R2\PocketPC\Include\Armv4i\winnt.h
2976 stasm

About this error:
Apart from the error, I was wondering why I have to include winnt.h
from such a specific Include lib. I would have thought it's under the
PSDK.

I guess you got your include directories wrong. Or was that VC6
project a PocketPC project?

Check your project properties for C++ and Linker if you find any of the
additional include or lib directories which point to the wrong locations
and remove them or replace them with correct paths.

Also check directories in "Tools->Options->Projects and Solutions"
 
Sven, you killed my bugs :-)
I included the Mobile SDK only because my previous project was asking
for missing include winnt.h, and the Mobile SDK was (as far as I
remember) the first location where I could find it.
When I removed it, all went fine :-)))
So great.
Kisses,
Anna
 
Anna Smidt said:
What is this

->

It is a C/C++ operator, useful when you have pointers to some data structure
or class instance, and you want access methods or data members in that
instance.

e.g.

class MyClass
{
public:
...

void DoSomething();

...
};

MyClass * pMyClass = new MyClass();

If you want to call MyClass::DoSomething() method given pMyClass pointer,
you can do:

pMyClass->DoSomething();

In the code you presented in the subject line of this post, the double 'p's
prefix makes me think that you have a double-pointer ppNullFilter, something
like:

SomeClass ** ppNullFilter;

So, the * inside the parenthesis (*ppNullFilter) gives you a single-pointer
(i.e. *ppNullFilter is of type SomeClass *, not SomeClass **).
And then you can use the operator-> as shown at the beginning of this post
(with a single pointer), to call AddRef() method.


Giovanni
 
If you want to call MyClass::DoSomething() method given pMyClass pointer,
you can do:

pMyClass->DoSomething();

So it's like "pMyClass.DoSomething" in VB6?
In the code you presented in the subject line of this post, the double 'p's
prefix makes me think that you have a double-pointer ppNullFilter, something
like:

SomeClass ** ppNullFilter;

What is a double-pointer, please??

Anna
 
Anna said:
So it's like "pMyClass.DoSomething" in VB6?

More or less, yes. The dot operator ('.') also exists in C++ and is used
when you have an instance of a structure or class, while you use the arrow
('->') operator when you have a pointer to an instance.
What is a double-pointer, please??

A pointer to a pointer (to something - e.g. an instance of SomeClass).

-cd
 
More or less, yes. The dot operator ('.') also exists in C++ and is used
when you have an instance of a structure or class, while you use the arrow
('->') operator when you have a pointer to an instance.

Why or when does somebody have a "pointer to a pointer of an instance"
instead of "an instance" or "a pointer to an instance"?

Greetings,
Anna
 
Why or when does somebody have a "pointer to a pointer of an instance"
instead of "an instance" or "a pointer to an instance"?

I think you should study some fundamental concepts about C related to
pointers.

VB6 or other environments hide the concept of pointers, but if you use
C/C++, you must have pointers knowledge.

The usual case of having "a pointer to a pointer of an instance" is when you
have a function or a method that returns a pointer to an instance as output
parameter.
e.g.

// Creates an instance of SomeClass class.
// The resulting instance is returned as 'ppSomeClassInstance' parameter.
// Returns true on success, false on error.
bool CreateSomeClassInstance(
SomeClass ** ppSomeClassInstance /* output parameter */
... some parameters ...
);

This use of double-pointer is done e.g. in COM IUnknown::QueryInterface (the
returned interface pointer is an output parameter for QueryInterface, so a
double-pointer is used).

You have a "pointer to an instance" when you don't want to pass instance "by
value" (forcing useless and expensive copy constructors and destructors
calls), but you want to pass "by pointer" or "by reference", I think that
this is similar to VB "ByRef" keyword (but I'm not a VB expert).

e.g.


class SomeClass;

void DoSomething( SomeClass x ); // x is an instance
void DoSomethingBetter( SomeClass * pX ); // pointer to instance of
SomeClass class

The second case just passes a pointer to the function, so there are no copy
constructor calls and no creation of temporary objects.
Passing by pointer is much more efficient especially if the class instance
is a big object, and has non-trivial copy semantics.
(Note that in C++ you can use references, that have a syntax similar to
passing by value, e.g. you can use operator dot instead of operator arrow,
but the semantics is similar to passing by pointer.)

....However, I think that you will have more details explanations about these
*important* C++ concepts if you spend some time reading some good book about
C++.

HTH,
Giovanni
 
Back
Top