![]() |
Do we need casting to match void * to char *
Why is it that the compiler complains "invalid conversion from void * to char*" when I do not cast it? Isn't void* supposed to be generic?
I have a bunch of files from another person which I am not allowed to edit, and he/she does not cast them. He/she argues that they are compatible without casting and it should work. Is it a compiler specific thing, where I should be setting some flags for it? Thanks in advance, everyone. Kurt |
Re: Do we need casting to match void * to char *
>Isn't void* supposed to be generic?
Yes, but that doesn't mean C++ allows an automatic conversion like C. You still have to cast it. |
Re: Do we need casting to match void * to char *
Quote:
But are there any compiler flags that can solve this? I've check the compiler manual, no such thing. So I'm wondering if there are common practice that does not cast it but still manage to compile. |
Re: Do we need casting to match void * to char *
>But are there any compiler flags that can solve this?
Um, there's nothing to solve. Type safety is a fundamental feature of C++. |
Re: Do we need casting to match void * to char *
> But are there any compiler flags that can solve this?
You mean like use a C compiler to compile C code perhaps? > I have a bunch of files from another person which I am not allowed to edit Why not? If they're really meant to be C++, then they're clearly wrong. |
Re: Do we need casting to match void * to char *
Quote:
If this is an instructor who has given you these files, and forbidden you to edit them, then you should slap them upside the head with a wet fish, and seek another school. |
Re: Do we need casting to match void * to char *
Quote:
Anyway, you guys are right. It was meant for C, and using the C instead of C++ compiler worked. Thanks guys! |
| All times are GMT -5. The time now is 3:58 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC