🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

*sighs* Another newbie question

Started by
4 comments, last by Miraj 24 years, 3 months ago
Quick brief: I am using Microsoft Visual C++. Okay, just when I thought I was finally gaining some ground on the differences between C & C++ I find myself hitting a brick wall. Last night as I was coding away happily I thought I would try to include a cool little snippet of source code into this project I''m attempting. So, I make a few adjustments and carry it on over and it doesn''t compile. The reason this confuses me is because when it was in its own Workspace/project it compiled and ran fine. So I started thinking, the usual, maybe I forgot to link a certain lib file or maybe a header. I investigated and that wasn''t the problem. I was stumped and getting desperate. I realized its original files had the extension .c, while the current project I''m working on are .cpp extensions. So, with this I tried two things. First I created another new project with the code snippets, except named the files .cpp instead of .c Sure enough, same errors. I changed them to .c and they compiled like a dream. So my question is, what do I have to do to make this code work with my current code (.cpp) files? Something is just not agreeing at all. I would rather not have to convert all of the snippet code (which is kind of alot, i guess I shouldn''t call it snippet) to C++, or do I not need to do that? Please tell me this is just some stupid thing I overlooked, or something I need to include somewhere to make it all work. -Miraj
-Miraj
Advertisement
What you are experiencing sounds like incompability between C and C++ (.c files are C and .cpp is C++), but I''m no C++ freak, so if you want people to help you with the code, post the errors and explain a little better.

============================
Daniel Netz, Sentinel Design
"I'm not stupid, I'm from Sweden" - Unknown
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
Well, okay most of the errors have the same ring to them. Something to the effect of "ERROR: Cannor convert unsigned char to *char" ...

That isn''t exactly it but those are the type I get, conversion errors. Does anyone know what I might do to get around this? I''ve tried everything, I''m at a loss...




-Miraj
-Miraj
Hmm, I don''t know why it would compile as .cpp but not as .c. I''ve had some problems like that with MSVC++ before and have had to reimport the entire project.





"When people tell you to tell the truth, you know that their lying."
C++ is more strict when it comes to implicit type conversions. You must add explicit typecasting to all those typecasting errors you get. For your informaition explicit typecasting is when you tell the compiler to cast the variable, for example with (char*)Variable.



Okay thank you guys, I''ll read up on how to do that and try it out. One more question, now I''m getting link errors...

"Unresolved external symbol _mode"
"Unresolved external symbol _done"

and so on ...

And I haven''t changed a thing, any ideas? ;(

This topic is closed to new replies.

Advertisement