Is it possible to compile and run c programs in the visual C++ .NE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a bunch of C programs from sun. I would like to port them over to PC.
I am wondering if I can simply recompile and run them in Visual C++ .NET
without
having to making a lot of changes? Specifically how to invoke C run time
library from Visaul C++ .NET?
 
Hi Kueishiong!
I have a bunch of C programs from sun. I would like to port them over to PC.
I am wondering if I can simply recompile and run them in Visual C++ .NET
without
having to making a lot of changes? Specifically how to invoke C run time
library from Visaul C++ .NET?

MS C++(.NET) is a "normal" C/C++ compiler, so you can just create a
project and insert all c/cpp-files.
It also supports the standard C-Runtime.
So there should be no "big" problem if you only relay on the CRT...

--
Greetings
Jochen

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

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? Also is it possible to have a
project with both C and C++ source files?
 
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/
 
Back
Top