0

Here is the problem:

Since there was a change in the code skeleton I was given, I had to somewhat modify my already-written codes to suit that minor change. Vast majority of the codes were still the same, so created a file with the same name and copy-paste the codes over, but now I received a very strange error:

error C2220: warning treated as error - no 'object' file generated

This error led me to this line of code:

new_message->message = malloc((int)strlen(s)+1);

Can any one help me please?

Thanks

4
Contributors
5
Replies
6
Views
11 Years
Discussion Span
Last Post by Ancient Dragon
0

Why are you casting strlen. There's no need for that.

there is if you use vc++ 2005 -- strlen() returns size_t (unsigned int) with that compiler.

0

>> error C2220: warning treated as error - no 'object' file generated

post the errors that appeared before that one. That error only says the compiler stopped because of previous errors.

0

there is if you use vc++ 2005 -- strlen() returns size_t (unsigned int) with that compiler.

Which is what malloc expects. Not much reason to explicitly cast a size_t to an int to have it implicitly cast to a size_t , I wouldn't think.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.