Click here to Skip to main content
15,885,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a project in plain c.But now i am required to embed that into MFC application Project. So can any one please tell me whether it is possible or not.If yes then how to do.If no then what to do.
Please don't tell me to create a .dll file, as i am using the current C project somewhere else. Sorry for inappropriate English and grammar.Thanks in advance.
[Edit]bold is removed-johny10151981[/Edit]
Posted
Updated 18-Jan-12 18:10pm
v2

There are two important things to do when adding C code to a C++ project:

1 - Select all .c files, right click to Properties, C++, Precompiled Headers, Precompiled Header and change "Use" to "Not Using Precompiled Headers".

2 - Open every .h file that relates to .c files and add at the beggining extern "C" { and close it with } at the end.

Remember that c code go in .c files and C++ code go in .cpp files.
 
Share this answer
 
What do you mean by embedding a project into another project?
What is the output of the C project - EXE/DLL/???

You use the source files in an MFC project by adding them as .C files into the MFC project.
If the output is an EXE, you can use ShellExecute/CreateProcess to invoke it from the MFC project.
If the output is a DLL or LIB, you can use as you would normally from the MFC project.
 
Share this answer
 
Comments
Mohibur Rashid 19-Jan-12 0:11am    
good one, hope the op will understand this
subrata kumar Nayak 19-Jan-12 1:07am    
Thanks for the reply....
actually the output is an EXE. i am not getting where to add .c,.h, files.
Please guide me...Thanks again...
«_Superman_» 19-Jan-12 1:37am    
Is that what you wish to do?
If so, right click on the MFC project in Solutions Explorer and select Add -> Existing Item and select the .C and .H files.
subrata kumar Nayak 19-Jan-12 2:26am    
thanks for the reply....
after adding the .c&.h file in the c++ project i am getting the error:Fatal Error C1853,then when i have done Not Using Precompiled Headers from precompiled headers of project properties i am getting Error:: error C2471: cannot update program database
«_Superman_» 19-Jan-12 2:40am    
Check if it works if you do a rebuild all.
Check this link - http://msdn.microsoft.com/en-us/library/zww6zdh7(v=vs.100).aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900