Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2006

Tip: Looking for answers? Try searching our database.

'void *' : unknown size

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Betsy - 24 Mar 2006 17:12 GMT
I'm trying to do some pointer manipulation and can not avoid using void * as
the type declaration. I get this error message : error C2036 : 'void *' :
unknown size though. Is there a compiler option or a way to tell the compiler
the size of void * to avoid this?

On a side note, when using W2003, I have this site defined as a trusted site
but the "new question" dialog is blocked as a popup (I had to go to a W2000
distribution). Popup blocked is disabled for Trusted sites, any idea how to
really disable the popup blocker ?

Thanks.
Betsy.
Bruno van Dooren - 24 Mar 2006 17:23 GMT
> I'm trying to do some pointer manipulation and can not avoid using void *
> as
> the type declaration. I get this error message : error C2036 : 'void *' :
> unknown size though. Is there a compiler option or a way to tell the
> compiler
> the size of void * to avoid this?

Your problem is that pointer arithmetic is dependent on the size of what the
pointer is pointing to:

int myArray[12];
int * test = &myArray[0];
test++;

the ++ operation moves the pointer not 1 byte, but sizeof(*test) bytes so
thaty it points to myArray[1];
void * does not have a type, so the compiler does not know what it should do
when + and - are applied. It does not point to anything that can be used for
size.

the solution is to cast to so what you mean it to be.
If you really want to do pointer aritmetic on a byte by byte basis, you have
to cast your pointer to char *.

Signature

Kind regards,
   Bruno van Dooren
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.