473,545 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\BaCCTe ster\Dev\Addins \Utils
\CommonDataMani pulators\Source s\CommonDataFre e.cpp 121
CommonDataManip ulators

and the problematic line of code is this:
....
FunctionRespons e* pFunctionRespon se =
ACE_dynamic_cas t(FunctionRespo nse*, 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
Feb 26 '08 #1
12 2967
ONE MORE THINK TO ADD:
RTTI is turned ON

On Feb 26, 10:33 am, "j123...@gmail. com" <j123...@gmail. comwrote:
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\BaCCTe ster\Dev\Addins \Utils
\CommonDataMani pulators\Source s\CommonDataFre e.cpp 121
CommonDataManip ulators

and the problematic line of code is this:
...
FunctionRespons e* pFunctionRespon se =
ACE_dynamic_cas t(FunctionRespo nse*, 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
Feb 26 '08 #2
On Feb 26, 10:33 am, "j123...@gmail. com" <j123...@gmail. comwrote:
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\BaCCTe ster\Dev\Addins \Utils
\CommonDataMani pulators\Source s\CommonDataFre e.cpp 121
CommonDataManip ulators
and the problematic line of code is this:
...
FunctionRespons e* pFunctionRespon se =
ACE_dynamic_cas t(FunctionRespo nse*, 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_cas t 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:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Feb 26 '08 #3
On Feb 26, 11:37 am, James Kanze <james.ka...@gm ail.comwrote:
On Feb 26, 10:33 am, "j123...@gmail. com" <j123...@gmail. comwrote:
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\BaCCTe ster\Dev\Addins \Utils
\CommonDataMani pulators\Source s\CommonDataFre e.cpp 121
CommonDataManip ulators
and the problematic line of code is this:
...
FunctionRespons e* pFunctionRespon se =
ACE_dynamic_cas t(FunctionRespo nse*, 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_cas t 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 objektorientier ter Datenverarbeitu ng
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_cas t(TYPE, EXPR) dynamic_cast<TY PE(EXPR)
actualy it is a standard dynamic_cast and it is from the ACE libraries
Feb 26 '08 #4
On Feb 26, 8:18*am, "j123...@gmail. com" <j123...@gmail. comwrote:
On Feb 26, 11:37 am, James Kanze <james.ka...@gm ail.comwrote:
On Feb 26, 10:33 am, "j123...@gmail. com" <j123...@gmail. comwrote:
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\BaCCT ester\Dev\Addin s\Utils
\CommonDataMani pulators\Source s\CommonDataFre e.cpp * * *121
CommonDataManip ulators
and the problematic line of code is this:
...
FunctionRespons e* pFunctionRespon se =
ACE_dynamic_cas t(FunctionRespo nse*, 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_cas t 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_cas t(TYPE, EXPR) dynamic_cast<TY PE(EXPR)
actualy it is a standard dynamic_cast and it is from the ACE libraries
<InigoMontoyaVo ice>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
Feb 26 '08 #5
äá á?
On Feb 26, 5:43 pm, Puppet_Sock <puppet_s...@ho tmail.comwrote:
On Feb 26, 8:18 am, "j123...@gmail. com" <j123...@gmail. comwrote:
On Feb 26, 11:37 am, James Kanze <james.ka...@gm ail.comwrote:
On Feb 26, 10:33 am, "j123...@gmail. com" <j123...@gmail. comwrote:
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\BaCCTe ster\Dev\Addins \Utils
\CommonDataMani pulators\Source s\CommonDataFre e.cpp 121
CommonDataManip ulators
and the problematic line of code is this:
...
FunctionRespons e* pFunctionRespon se =
ACE_dynamic_cas t(FunctionRespo nse*, 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_cas t 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_cas t(TYPE, EXPR) dynamic_cast<TY PE(EXPR)
actualy it is a standard dynamic_cast and it is from the ACE libraries

<InigoMontoyaVo ice>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
Feb 26 '08 #6
j1*****@gmail.c om wrote:
On Feb 26, 11:37 am, James Kanze <james.ka...@gm ail.comwrote:
>On Feb 26, 10:33 am, "j123...@gmail. com" <j123...@gmail. comwrote:
>>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\BaCCTe ster\Dev\Addins \Utils
\CommonDataMa nipulators\Sour ces\CommonDataF ree.cpp 121
CommonDataMan ipulators
and the problematic line of code is this:
...
FunctionRespo nse* pFunctionRespon se =
ACE_dynamic_c ast(FunctionRes ponse*, 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_cas t 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 objektorientier ter Datenverarbeitu ng
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_cas t(TYPE, EXPR) dynamic_cast<TY PE(EXPR)
actualy it is a standard dynamic_cast and it is from the ACE
libraries
And now, what is FunctionRespons e and data. Could any of them be void?
Bo Persson
Feb 26 '08 #7
On 26 Feb., 17:43, Puppet_Sock <puppet_s...@ho tmail.comwrote:
On Feb 26, 8:18*am, "j123...@gmail. com" <j123...@gmail. comwrote:


On Feb 26, 11:37 am, James Kanze <james.ka...@gm ail.comwrote:
On Feb 26, 10:33 am, "j123...@gmail. com" <j123...@gmail. comwrote:
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\BaCCT ester\Dev\Addin s\Utils
\CommonDataMani pulators\Source s\CommonDataFre e.cpp * * *121
CommonDataManip ulators
and the problematic line of code is this:
...
FunctionRespons e* pFunctionRespon se =
ACE_dynamic_cas t(FunctionRespo nse*, data);
[snip]
The real question is what ACE_dynamic_cas t 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_cas t(TYPE, EXPR) dynamic_cast<TY PE(EXPR)
actualy it is a standard dynamic_cast and it is from the ACE libraries

<InigoMontoyaVo ice>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
Feb 26 '08 #8
j1*****@gmail.c om 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
Feb 26 '08 #9
On 26 Feb., 10:33, "j123...@gmail. com" <j123...@gmail. comwrote:
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\BaCCT ester\Dev\Addin s\Utils
\CommonDataMani pulators\Source s\CommonDataFre e.cpp * * *121
CommonDataManip ulators

and the problematic line of code is this:
...
FunctionRespons e* pFunctionRespon se =
ACE_dynamic_cas t(FunctionRespo nse*, 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 FunctionRespons e is of type void, the code
above should not work.
Visual Studio 6 probably got this wrong - it is a very old compiler.

/Peter
Feb 26 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
2199
by: dkcpub | last post by:
I'm very new to Python, but I couldn't find anything in the docs or faq about this. And I fished around in the IDLE menus but didn't see anything. Is there a tool that can determine all the exceptions that can be raised in a Python function, or in any of the functions it calls, etc.? /Dan
3
2175
by: Martin Mrazek | last post by:
Hi, I have tables named like ag97a027, ag98a027, ... where 97 and 98 is from year 1997, 1998 and a027 is just specification of product type. I need carry out repeated operataions over these tables. To generate their names is easy, for example use declare @Yint int, @Y char(2), @tabName char(8) set @Yint = 1997 while @Yint < 2002
68
3948
by: Ted Nicols | last post by:
That's what I keep asking myself whenever develop in .NET. Is this a joke a farse or just a bad dream? ..NET is slow, actually slow is just a polite word I can use in a newsgroup. ..NET is just a VM and as one it works very slowly, before and after JIT. I don't understand why some people insist that a VM can be compared with native...
7
1877
by: Jacek Dziedzic | last post by:
Hi! I'm trying to make friends with exceptions. I think I'm doing well, there is one thing that bothers me, however. If an object is declared within a try block, it gets destroyed on exception, because then we're into the catch block and out of the try block, right? How can I sense in the destructor that we're in the middle of processing...
14
2004
by: TT (Tom Tempelaere) | last post by:
Hi people, The code that follows throws an ExecutionEngineException. This was written in C# (Microsoft Visual C# .NET 69462-335-0000007-18823) using MSDE 7.1 (7.1.3088). The framework is .NET 1.1 (1.1.4322). I tested the program on a Windows XP Professional/SP1, with a Pentium 4/2.6Ghz processor, with 2Gb RAM. The code is a single form...
12
1913
by: Steven Bethard | last post by:
Ok, so I have a module that is basically a Python wrapper around a big lookup table stored in a text file. The module needs to provide a few functions:: get_stem(word, pos, default=None) stem_exists(word, pos) ... Because there should only ever be one lookup table, I feel like these functions ought to be module globals. That way, you...
2
6017
by: Rodney Dunning | last post by:
Forgive me if this is a stupid question. I have a course syllabus located at http://www.longwood.edu/staff/dunningrb/teaching/easc101f06/easc101f06_syllabus.html. I use a <divcontainer for the main content of the page. When I print the page, or select Print Preview, I get only a single sheet, even the though the content should run to...
15
1828
by: Steven T. Hatton | last post by:
I found the example code below, listed in the book described here: http://cartan.cas.suffolk.edu/moin/OopDocbookWiki The result was a bit surprising. I guess it falls into the category of "that's what you get for lying". Can the behavior demonstrated be explained in standardese? Yes, I know the exact result is "undefined behavior". I...
0
1817
by: P Pulkkinen | last post by:
Dear all, sorry, i know this code is far little too long to debug here, but there is really annoying logical error. If someone debugs this, I really offer warm virtual handshake. What this code SHOULD do: - read new (=updated) licensetext from file $license_path then - read and modify recursively all files from $current_dir, replacing...
0
7408
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7433
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7763
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5976
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5340
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1891
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.