PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.cplus > A Question that really bothers me...
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
A Question that really bothers me...

Réponse
 
LinkBack Outils de la discussion
Vieux 26/02/2008, 09h33   #1
j1230xz@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut A Question that really bothers me...

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 ,
references, links and so are highly appriciated.

Thank You,
Nikola Tanev
  Réponse avec citation
Vieux 26/02/2008, 09h35   #2
j1230xz@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A Question that really bothers me...

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 ,
> references, links and so are highly appriciated.
>
> Thank You,
> Nikola Tanev


  Réponse avec citation
Vieux 26/02/2008, 10h37   #3
James Kanze
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A Question that really bothers me...

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 , 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.kanze@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
  Réponse avec citation
Vieux 26/02/2008, 13h18   #4
j1230xz@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A Question that really bothers me...

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 , 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
  Réponse avec citation
Vieux 26/02/2008, 16h43   #5
Puppet_Sock
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A Question that really bothers me...

On Feb 26, 8:18am, "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 , 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 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
  Réponse avec citation
Vieux 26/02/2008, 17h06   #6
j1230xz@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A Question that really bothers me...

äá á?


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 , 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 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


  Réponse avec citation
Vieux 26/02/2008, 17h41   #7
Bo Persson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A Question that really bothers me...

j1230xz@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 , 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


  Réponse avec citation
Vieux 26/02/2008, 17h52   #8
peter koch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: A Question that really bothers me...

On 26 Feb., 17:43, Puppet_Sock <puppet_s...@hotmail.com> wrote:
> On Feb 26, 8:18am, "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 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
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h17.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19130 seconds with 16 queries