Advertisement

Are you good with Dev Studio?

Started by June 13, 2001 09:53 PM
3 comments, last by cOrUptKid 23 years, 8 months ago
Then could you please help me, im making a game using a direct draw shell, however I decided to store all my header and object systems in other files. During the process of this, visual studio started to tell me that i could not call a C++ fuction from a C file. I know how to do it the othere way round using extern "C", but could you please tell me how you call a c++ function from a C file, Cheers Edited by - cOrUptKid on June 13, 2001 10:57:28 PM
Hmmm...
Well that depends on what you mean by a C++ function. lol

C++ extends C and not the other way around. Almost anything in C can be used equivocally in C++. But C++ has alot of functionality that is not directly supported by C. Classes for instance

There is a way that you can operate on C++ classes in a straight C file but it requires that you understand the C++ class architecture on a low level. (A class can be treated as a structure with a pointer to class information and other variables... but the variable names are not going to be the same.) If that is what you want to do and are interested in learning how to do it let me know and I will post an example.

Stream and overloaded operators. Well. Can''t help ya.

But is there a reason that you are using C files? If you want to use C++ functionality, use CPP files

Seeya
Krippy
Advertisement
that wasnt exactly what i meand i ment calling an ordinary function i.e "update_sprite()" from a C file, however i have picked up on something else you said and realised going down this path would just make life more dificult when my engine gets abit more complicated, is it possible simply to block copy code int o a c++ file, and if so how do you declaire them in another c++ file. If transfering the code is far too much hassel then could you please tell me how to call an ordinary c++ function or variable from a c file, i apreciate your help thanx.
that wasnt exactly what i meand i ment calling an ordinary function i.e "update_sprite()" from a C file, however i have picked up on something else you said and realised going down this path would just make life more dificult when my engine gets abit more complicated, is it possible simply to block copy code int o a c++ file, and if so how do you declaire them in another c++ file. If transfering the code is far too much hassel then could you please tell me how to call an ordinary c++ function or variable from a c file, i apreciate your help thanx.
If you have a file "foobar.c" simply rename it to "foobar.cpp", that should work most of the time. You might have to do minor modifications, but just try it, it should work.

This topic is closed to new replies.

Advertisement