# Solved: C in visual studio



## php guy (Dec 17, 2004)

So I installed visual studio 2005 on my desktop and have been able to create and compile C programs just fine. I recently put it on my laptop and installed the SPs. I create a win32 Console Application and make it a blank project, same as I do on my desktop.

Only problem is, when I go to add a new item then use a .c extension (again, same as my pc), I get this error that says "You are adding a CLR component to a native project. Your project will be converted to have Common Language Runtime support. Do you wish to continue?" If I hit yes, it creates a .cpp and .h file instead of a .c file. So what am I doing wrong here? 

Thanks


----------



## mt2002 (Sep 14, 2005)

How exactally are you adding the new .c file?


----------



## php guy (Dec 17, 2004)

Right clicking Source Files in the Solution Explorer, add > new item, then typing out whatever.c

Is there a better way?


----------



## pvc_ (Feb 18, 2008)

can't you just create a console cpp file, and then rename it? if it converts it to a .net class, just goto the application dependencies and remove the .net namespaces. Although, it sounds really odd that it does that.


----------



## shannon08 (Jul 30, 2008)

Hey, thanx for sharing actually I wanted to add my laptop, your tips helps a lot to add.


----------



## IMM (Feb 1, 2002)

Is _/clr_ defined in your project?
If no satisfaction from removing that then you could always try adding _#pragma unmanaged_ to the top of your .c addition

some info on it at http://msdn.microsoft.com/en-us/library/0adb9zxe(VS.80).aspx


----------



## mt2002 (Sep 14, 2005)

Rather then creating a win32 Console Application, try just creating a "blank project":

1. Go to File->New project;
2. On the left pane under project types, go to Visual C++ -> General. The right pane should update.
3. On the right pane, select Empty project. Type in your new project name (And select create new directory for solution if you want it), and hit Ok to create the project.

Try to add your C files after doing this and let us know what happens.

I know my version of Visual C++ comes with CLR templates that, if selected, will enable CLR for your project--which doesnt seem to be what you want. Creating a blank project will only have basic default settings applied to your project and adds no additional files.

You can create any type of project--Win32 console, Win32 application, driver, et al... from an empty project so you are not limited.


----------



## php guy (Dec 17, 2004)

Thanks for the replies.

I got it to work by just adding a c++ file from the start then changing the extension after it was added.


----------

