Using C in MSVC++ 2010

Is there a way to use C or create and compile a .c file in Microsoft Visual C++ 2010 Express? I know with older versions it is possible but it doesn't seem to be now. Also, if I write the function in NotePad and add it to my MSVC++ project, will that work?
Also, if I write the function in NotePad and add it to my MSVC++ project, will that work?


Why donĀ“t You use the IDE for this?...

And Yes... it is possible...
How? When I try to start a new .c file it only allows .cpp and .h(pp). No .c. And it also doesn't allow you to change the language from C++ to C, or at least not where I looked (The Project Properties under C/C++ tab)
closed account (z05DSL3A)
When you give the file a name just use the .c file extension.
1) If you are going to write functions and whatnot in notepad, that's fine. You just have to save it as a '.cpp' file or in your case, a '.c' file.

2) I don't think you can compile C in MSVC++ note the 'C++' at the end. What you can do is convert a C project into C++. But I don't think you want to do that. I think you'll need a C compiler.
Last edited on
closed account (1yR4jE8b)
After you've created the 'cpp' file, you can simply rename the file to '.c' if you want.
You will be able to include standard C Library header files, and compilation will even fail if you try to include any standard C++ library header files.

@Serpent:
A C++ compiler IS a C compiler, any code that is compilable using a C compiler should be compilable using a C++ compiler. That's part of the C++ standard.
That is what I thought after too. But then I didn't bother trying out C code or something. I had thought of this since if you go to "Project > Properties" it says somewhere "C/C++". So... Yeah!
When I try to start a new .c file it only allows .cpp and .h(pp). No .c. And it also doesn't allow you to change the language from C++ to C, or at least not where I looked (The Project Properties under C/C++ tab),for futher information regarding brandy, please refer to:www.brideswardrobe.com/7-wedding-dress
You can create a *.c -file via another editor and import it via "Add existing Item..."


btw... what is so important about the c or cpp-file-extension?...
With Visual Studios (and I think any other compiler) you can even compile *.txt-files with code inside (when using the command line)...
Last edited on
closed account (z05DSL3A)
Incubbus wrote:
btw... what is so important about the c or cpp-file-extension?

Giving your files the .c extension, for example mysource.c, the Visual C++ compiler automatically assumes that files with the .C extension are C files and not C++ files, and rejects C++ syntax and keywords (such as public, private, and class).

kooti wrote:
When I try to start a new .c file it only allows .cpp and .h(pp). No .c.

I'll say it again for the hard of reading. When you add a new item, select 'C++ file' and give it an name with a .c extension. i.e. somename.c this is then saved as a C file.

Edit:
And it also doesn't allow you to change the language from C++ to C, or at least not where I looked (The Project Properties under C/C++ tab)

For this you go to the Property Pages, select the C/C++ -> Advanced page and change the Compile As setting.
Last edited on
Topic archived. No new replies allowed.