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

Recommended Answers

All 5 Replies

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

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.

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

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.

Yes, Dave, my comment was incorrect.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.