Re: Is it possible to compile and run c programs in the visual C++



Hi Kueishiong!

When I create a new console project, the template main function created is always a C++ file from VC++ .NET. Is it possible to create a new project with the template main function created a C file?

There is no template for C-files. But you can simply rename the "cpp"-extension to "c" (or delete the file and create a new one).


You also should be sure to disable "pre-compiled headers" (in project properties "C/C++|Precompiled headers".

Also is it possible to have a project with both C and C++ source files?

Yes, there is no problem with that.

Just a small note:
If you want to include "c"-headerfiles then you must be sure that you put the following around them (or include this in the h-file):


#ifdef __cplusplus
extern "C" {
#endif

#include "your-c-h-file.h"

#ifdef __cplusplus
}
#endif


-- Greetings Jochen

   My blog about Win32 and .NET
   http://blog.kalmbachnet.de/
.



Relevant Pages


Quantcast