Are you good with Dev Studio?
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![](wink.gif)
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![](wink.gif)
Seeya
Krippy
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
![](wink.gif)
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
![](wink.gif)
Seeya
Krippy
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement