Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > A Question that really bothers me...

Reply
Thread Tools

A Question that really bothers me...

 
 
j1230xz@gmail.com
Guest
Posts: n/a
 
      02-26-2008
Ok now the problem is this.

I have compiled some old code with Visual Studio 2008 (the code was
originally writen in Visual Studio 6) and i have this error:

Error 1 error C2681: 'void *' : invalid expression type for
dynamic_cast c:\Works\BaCCTester\Dev\Addins\Utils
\CommonDataManipulators\Sources\CommonDataFree.cpp 121
CommonDataManipulators

and the problematic line of code is this:
....
FunctionResponse* pFunctionResponse =
ACE_dynamic_cast(FunctionResponse*, data);
....

So it is logicaly that dynamic_cast does not work for void-pointers
since when I converted the pointer to void I have given up all type
information. But what makes me think twice about the corectness of the
previous sentence is that this code compiles perfectly under Visual
Studio 6. I would like to know more about this issue so any help,
references, links and so are highly appriciated.

Thank You,
Nikola Tanev
 
Reply With Quote
 
 
 
 
j1230xz@gmail.com
Guest
Posts: n/a
 
      02-26-2008
ONE MORE THINK TO ADD:
RTTI is turned ON

On Feb 26, 10:33 am, "j123...@gmail.com" <j123...@gmail.com> wrote:
> Ok now the problem is this.
>
> I have compiled some old code with Visual Studio 2008 (the code was
> originally writen in Visual Studio 6) and i have this error:
>
> Error 1 error C2681: 'void *' : invalid expression type for
> dynamic_cast c:\Works\BaCCTester\Dev\Addins\Utils
> \CommonDataManipulators\Sources\CommonDataFree.cpp 121
> CommonDataManipulators
>
> and the problematic line of code is this:
> ...
> FunctionResponse* pFunctionResponse =
> ACE_dynamic_cast(FunctionResponse*, data);
> ...
>
> So it is logicaly that dynamic_cast does not work for void-pointers
> since when I converted the pointer to void I have given up all type
> information. But what makes me think twice about the corectness of the
> previous sentence is that this code compiles perfectly under Visual
> Studio 6. I would like to know more about this issue so any help,
> references, links and so are highly appriciated.
>
> Thank You,
> Nikola Tanev


 
Reply With Quote
 
 
 
 
James Kanze
Guest
Posts: n/a
 
      02-26-2008
On Feb 26, 10:33 am, "j123...@gmail.com" <j123...@gmail.com> wrote:
> Ok now the problem is this.


> I have compiled some old code with Visual Studio 2008 (the
> code was originally writen in Visual Studio 6) and i have this
> error:


> Error 1 error C2681: 'void *' : invalid expression type for
> dynamic_cast c:\Works\BaCCTester\Dev\Addins\Utils
> \CommonDataManipulators\Sources\CommonDataFree.cpp 121
> CommonDataManipulators


> and the problematic line of code is this:
> ...
> FunctionResponse* pFunctionResponse =
> ACE_dynamic_cast(FunctionResponse*, data);
> ...


> So it is logicaly that dynamic_cast does not work for
> void-pointers since when I converted the pointer to void I
> have given up all type information. But what makes me think
> twice about the corectness of the previous sentence is that
> this code compiles perfectly under Visual Studio 6. I would
> like to know more about this issue so any help, references,
> links and so are highly appriciated.


The real question is what ACE_dynamic_cast is. I suspect that
it's a macro, and probably expands differently depending on the
compiler, but I really don't know.

--
James Kanze (GABI Software) email:
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
 
Reply With Quote
 
j1230xz@gmail.com
Guest
Posts: n/a
 
      02-26-2008
On Feb 26, 11:37 am, James Kanze <james.ka...@gmail.com> wrote:
> On Feb 26, 10:33 am, "j123...@gmail.com" <j123...@gmail.com> wrote:
>
>
>
> > Ok now the problem is this.
> > I have compiled some old code with Visual Studio 2008 (the
> > code was originally writen in Visual Studio 6) and i have this
> > error:
> > Error 1 error C2681: 'void *' : invalid expression type for
> > dynamic_cast c:\Works\BaCCTester\Dev\Addins\Utils
> > \CommonDataManipulators\Sources\CommonDataFree.cpp 121
> > CommonDataManipulators
> > and the problematic line of code is this:
> > ...
> > FunctionResponse* pFunctionResponse =
> > ACE_dynamic_cast(FunctionResponse*, data);
> > ...
> > So it is logicaly that dynamic_cast does not work for
> > void-pointers since when I converted the pointer to void I
> > have given up all type information. But what makes me think
> > twice about the corectness of the previous sentence is that
> > this code compiles perfectly under Visual Studio 6. I would
> > like to know more about this issue so any help, references,
> > links and so are highly appriciated.

>
> The real question is what ACE_dynamic_cast is. I suspect that
> it's a macro, and probably expands differently depending on the
> compiler, but I really don't know.
>
> --
> James Kanze (GABI Software) email:james.ka...@gmail.com
> Conseils en informatique orientée objet/
> Beratung in objektorientierter Datenverarbeitung
> 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


Yes it is a macro
# define ACE_dynamic_cast(TYPE, EXPR) dynamic_cast<TYPE> (EXPR)
actualy it is a standard dynamic_cast and it is from the ACE libraries
 
Reply With Quote
 
Puppet_Sock
Guest
Posts: n/a
 
      02-26-2008
On Feb 26, 8:18*am, "j123...@gmail.com" <j123...@gmail.com> wrote:
> On Feb 26, 11:37 am, James Kanze <james.ka...@gmail.com> wrote:
>
> > On Feb 26, 10:33 am, "j123...@gmail.com" <j123...@gmail.com> wrote:

>
> > > Ok now the problem is this.
> > > I have compiled some old code with Visual Studio 2008 (the
> > > code was originally writen in Visual Studio 6) and i have this
> > > error:
> > > Error * 1 * * * error C2681: 'void *' : invalid expression type for
> > > dynamic_cast * *c:\Works\BaCCTester\Dev\Addins\Utils
> > > \CommonDataManipulators\Sources\CommonDataFree.cpp * * *121
> > > CommonDataManipulators
> > > and the problematic line of code is this:
> > > ...
> > > FunctionResponse* pFunctionResponse =
> > > ACE_dynamic_cast(FunctionResponse*, data);
> > > ...
> > > So it is logicaly that dynamic_cast does not work for
> > > void-pointers since when I converted the pointer to void I
> > > have given up all type information. But what makes me think
> > > twice about the corectness of the previous sentence is that
> > > this code compiles perfectly under Visual Studio 6. I would
> > > like to know more about this issue so any help, references,
> > > links and so are highly appriciated.

>
> > The real question is what ACE_dynamic_cast is. *I suspect that
> > it's a macro, and probably expands differently depending on the
> > compiler, but I really don't know.

>
> Yes it is a macro
> # * define ACE_dynamic_cast(TYPE, EXPR) dynamic_cast<TYPE> (EXPR)
> actualy it is a standard dynamic_cast and it is from the ACE libraries


<InigoMontoyaVoice>You keep using that word. I do not think
it means what you think it means.</voice>

In this news group, "standard" means part of the standard
C++ language, not part of a commercial library, no matter
how many people use it.

As to your original question:
- Did you read the help files for VS?

Compiler Error C2681
> A casting operator tried to convert from an invalid type.
> For example, if you use the dynamic_cast operator to
> convert an expression to a pointer type, the source
> expression must be a pointer.


- Did you consider asking your question in a news group
dealing with VS?

As to what older versions of VS would do: Older versions
were feydasque but fun. Lots of whacky things they did,
for many reasons, most of which are a bit off topic here.
Socks
 
Reply With Quote
 
j1230xz@gmail.com
Guest
Posts: n/a
 
      02-26-2008
äá á?


On Feb 26, 5:43 pm, Puppet_Sock <puppet_s...@hotmail.com> wrote:
> On Feb 26, 8:18 am, "j123...@gmail.com" <j123...@gmail.com> wrote:
>
>
>
> > On Feb 26, 11:37 am, James Kanze <james.ka...@gmail.com> wrote:

>
> > > On Feb 26, 10:33 am, "j123...@gmail.com" <j123...@gmail.com> wrote:

>
> > > > Ok now the problem is this.
> > > > I have compiled some old code with Visual Studio 2008 (the
> > > > code was originally writen in Visual Studio 6) and i have this
> > > > error:
> > > > Error 1 error C2681: 'void *' : invalid expression type for
> > > > dynamic_cast c:\Works\BaCCTester\Dev\Addins\Utils
> > > > \CommonDataManipulators\Sources\CommonDataFree.cpp 121
> > > > CommonDataManipulators
> > > > and the problematic line of code is this:
> > > > ...
> > > > FunctionResponse* pFunctionResponse =
> > > > ACE_dynamic_cast(FunctionResponse*, data);
> > > > ...
> > > > So it is logicaly that dynamic_cast does not work for
> > > > void-pointers since when I converted the pointer to void I
> > > > have given up all type information. But what makes me think
> > > > twice about the corectness of the previous sentence is that
> > > > this code compiles perfectly under Visual Studio 6. I would
> > > > like to know more about this issue so any help, references,
> > > > links and so are highly appriciated.

>
> > > The real question is what ACE_dynamic_cast is. I suspect that
> > > it's a macro, and probably expands differently depending on the
> > > compiler, but I really don't know.

>
> > Yes it is a macro
> > # define ACE_dynamic_cast(TYPE, EXPR) dynamic_cast<TYPE> (EXPR)
> > actualy it is a standard dynamic_cast and it is from the ACE libraries

>
> <InigoMontoyaVoice>You keep using that word. I do not think
> it means what you think it means.</voice>
>
> In this news group, "standard" means part of the standard
> C++ language, not part of a commercial library, no matter
> how many people use it.
>
> As to your original question:
> - Did you read the help files for VS?
>
> Compiler Error C2681
>
> > A casting operator tried to convert from an invalid type.
> > For example, if you use the dynamic_cast operator to
> > convert an expression to a pointer type, the source
> > expression must be a pointer.

>
> - Did you consider asking your question in a news group
> dealing with VS?
>
> As to what older versions of VS would do: Older versions
> were feydasque but fun. Lots of whacky things they did,
> for many reasons, most of which are a bit off topic here.
> Socks


 
Reply With Quote
 
Bo Persson
Guest
Posts: n/a
 
      02-26-2008
wrote:
> On Feb 26, 11:37 am, James Kanze <james.ka...@gmail.com> wrote:
>> On Feb 26, 10:33 am, "j123...@gmail.com" <j123...@gmail.com> wrote:
>>
>>
>>
>>> Ok now the problem is this.
>>> I have compiled some old code with Visual Studio 2008 (the
>>> code was originally writen in Visual Studio 6) and i have this
>>> error:
>>> Error 1 error C2681: 'void *' : invalid expression type
>>> for dynamic_cast c:\Works\BaCCTester\Dev\Addins\Utils
>>> \CommonDataManipulators\Sources\CommonDataFree.cpp 121
>>> CommonDataManipulators
>>> and the problematic line of code is this:
>>> ...
>>> FunctionResponse* pFunctionResponse =
>>> ACE_dynamic_cast(FunctionResponse*, data);
>>> ...
>>> So it is logicaly that dynamic_cast does not work for
>>> void-pointers since when I converted the pointer to void I
>>> have given up all type information. But what makes me think
>>> twice about the corectness of the previous sentence is that
>>> this code compiles perfectly under Visual Studio 6. I would
>>> like to know more about this issue so any help, references,
>>> links and so are highly appriciated.

>>
>> The real question is what ACE_dynamic_cast is. I suspect that
>> it's a macro, and probably expands differently depending on the
>> compiler, but I really don't know.
>>
>> --
>> James Kanze (GABI Software) email:james.ka...@gmail.com
>> Conseils en informatique orientée objet/
>> Beratung in objektorientierter Datenverarbeitung
>> 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

>
> Yes it is a macro
> # define ACE_dynamic_cast(TYPE, EXPR) dynamic_cast<TYPE> (EXPR)
> actualy it is a standard dynamic_cast and it is from the ACE
> libraries


And now, what is FunctionResponse and data. Could any of them be void?


Bo Persson


 
Reply With Quote
 
peter koch
Guest
Posts: n/a
 
      02-26-2008
On 26 Feb., 17:43, Puppet_Sock <puppet_s...@hotmail.com> wrote:
> On Feb 26, 8:18*am, "j123...@gmail.com" <j123...@gmail.com> wrote:
>
>
>
>
>
> > On Feb 26, 11:37 am, James Kanze <james.ka...@gmail.com> wrote:

>
> > > On Feb 26, 10:33 am, "j123...@gmail.com" <j123...@gmail.com> wrote:

>
> > > > Ok now the problem is this.
> > > > I have compiled some old code with Visual Studio 2008 (the
> > > > code was originally writen in Visual Studio 6) and i have this
> > > > error:
> > > > Error * 1 * * * error C2681: 'void *' : invalid expression type for
> > > > dynamic_cast * *c:\Works\BaCCTester\Dev\Addins\Utils
> > > > \CommonDataManipulators\Sources\CommonDataFree.cpp * * *121
> > > > CommonDataManipulators
> > > > and the problematic line of code is this:
> > > > ...
> > > > FunctionResponse* pFunctionResponse =
> > > > ACE_dynamic_cast(FunctionResponse*, data);

[snip]
> > > The real question is what ACE_dynamic_cast is. *I suspect that
> > > it's a macro, and probably expands differently depending on the
> > > compiler, but I really don't know.

>
> > Yes it is a macro
> > # * define ACE_dynamic_cast(TYPE, EXPR) dynamic_cast<TYPE> (EXPR)
> > actualy it is a standard dynamic_cast and it is from the ACE libraries

>
> <InigoMontoyaVoice>You keep using that word. I do not think
> it means what you think it means.</voice>
>
> In this news group, "standard" means part of the standard
> C++ language, not part of a commercial library, no matter
> how many people use it.


But we found out that it really was a dynamic_cast (the errormessage
itself did show that if you read carefull), and in that case the
question definitely is standard, no matter if this is hidden inside
some hideous macro.

>
> As to your original question:
> - Did you read the help files for VS?
>
> Compiler Error C2681
>
> > A casting operator tried to convert from an invalid type.
> > For example, if you use the dynamic_cast operator to
> > convert an expression to a pointer type, the source
> > expression must be a pointer.

>
> - Did you consider asking your question in a news group
> * dealing with VS?
>

This question would only be appropriate in case the answer here
indicated that VS has a nonstandard behaviour.

[snip]

/Peter
 
Reply With Quote
 
Andrey Tarasevich
Guest
Posts: n/a
 
      02-26-2008
wrote:
> information. But what makes me think twice about the corectness of the
> previous sentence is that this code compiles perfectly under Visual
> Studio 6.


VC6 reports the same error when 'dynamic_cast' is applied to a 'void*'
expression.

This means that it is absolutely impossible to figure out why it
compiled in VC6 from the information you provided so far. It could be
that in VC6 the expression was not 'void*' somehow. Or it could be that
in VC6 the macro was actually mapped to 'static_cast'. Or something else.

--
Best regards,
Andrey Tarasevich
 
Reply With Quote
 
peter koch
Guest
Posts: n/a
 
      02-26-2008
On 26 Feb., 10:33, "j123...@gmail.com" <j123...@gmail.com> wrote:
> Ok now the problem is this.
>
> I have compiled some old code with Visual Studio 2008 (the code was
> originally writen in Visual Studio 6) and i have this error:
>
> Error * 1 * * * error C2681: 'void *' : invalid expression type for
> dynamic_cast * *c:\Works\BaCCTester\Dev\Addins\Utils
> \CommonDataManipulators\Sources\CommonDataFree.cpp * * *121
> CommonDataManipulators
>
> and the problematic line of code is this:
> ...
> FunctionResponse* pFunctionResponse =
> ACE_dynamic_cast(FunctionResponse*, data);
> ...
>
> So it is logicaly that dynamic_cast does not work for void-pointers
> since when I converted the pointer to void I have given up all type
> information. But what makes me think twice about the corectness of the
> previous sentence is that this code compiles perfectly under Visual
> Studio 6. I would like to know more about this issue so any help,
> references, links and so are highly appriciated.
>


If data is of type void* or FunctionResponse is of type void, the code
above should not work.
Visual Studio 6 probably got this wrong - it is a very old compiler.

/Peter
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Forms Authentication - Really really basic question LW ASP .Net Security 1 05-02-2007 11:25 AM
Forms Authentication - Really really basic question =?Utf-8?B?TFc=?= ASP .Net 8 04-24-2007 11:54 PM
Just ordered from cameraworld.com, but something bothers me. ripplesoflife Digital Photography 5 04-14-2007 06:21 AM
REALLY REALLY WERID PROBLEM!!!!pls take a look Amir ASP .Net 3 01-23-2004 06:01 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57