View Full Version : Visual Studio help
TouGe
06-11-2007, 12:34 PM
Hello everyone. Can someone here tell me how to compile code in C using Visual Studio 2005? I've used VS to write and compile C++ code but this is the first time I've used it to write in C.
When I go to 'add new item' the only option I get in relation to C is 'C++ File (.cpp)'. Now correct me if I am wrong but don't I need '.c' for a file extension to compile a program in C? I tried to compile a short program in C using the 'C++ File(.cpp)' but all I got were errors.
Any suggestions?
http://img413.imageshack.us/img413/2725/addnewitemsr8.th.png (http://img413.imageshack.us/my.php?image=addnewitemsr8.png)
nn_step
06-11-2007, 01:09 PM
just a thought http://wxdsgn.sourceforge.net/
TouGe
06-12-2007, 04:07 AM
Wow, that actually looks pretty interesting. Thanks for pointing me in that direction. I've been googling on and off over the past couple of days trying to figure this out and I never came across this site. I appreciate it nn_step.
wforl
06-12-2007, 11:09 AM
Anything written in C should compile fine in c++, show us your code
_Slim_Shady_
06-13-2007, 06:13 PM
Just open up the Visual Studio Command Prompt and type:
cl myClass.c
TouGe
06-13-2007, 10:36 PM
Anything written in C should compile fine in c++, show us your code
You are correct. I guess I must have done something wrong but I was under the impression that to compile in C you had to use .c file extension and .cpp for C++.
There is no option to choose this in VS 2005, only C++ File(.cpp).
Will I run into problems in the future when I try to compile more complex C code under C++?
TouGe
06-13-2007, 10:45 PM
Just open up the Visual Studio Command Prompt and type:
cl myClass.c
:confused:
http://img461.imageshack.us/img461/139/vs2005cpxt6.th.png (http://img461.imageshack.us/my.php?image=vs2005cpxt6.png)
Heretic
06-14-2007, 05:49 AM
Replace "myClass.c" with whatever your source file is....or if it is called myClass.c, make sure the path to the file is correct since it's probably not in the VC folder.
_Slim_Shady_
06-14-2007, 06:19 PM
:confused:
http://img461.imageshack.us/img461/139/vs2005cpxt6.th.png (http://img461.imageshack.us/my.php?image=vs2005cpxt6.png)
LOL...OK don't literally type cl myClass.c :D
cd to the directory containing your class file, and the replace myClass.c with the name of your file. cl /? will show you all of the options. There's a ton of options, and you'd be well-advised to visit MSDN to find the one's appropriate to your needs.
By the way, what are you writing in C?
If you are just learning to program download C# Express Edition from MSDN It's free, and C# is a fun language to learn. It's a managed language so you don't need to worry about pointers...even though understanding pointers is always a good idea. :cool: Plus you can get cheeky, and wrap your code block in unsafe { ... } and have at it with the pointers if you like. ;)
If you like games you can also get XNA Studio which will allow you to write a game, and play it on your XBox 360.
TouGe
06-14-2007, 11:34 PM
LOL...OK don't literally type cl myClass.c
LOL, yeah I kind of realized that a couple of minutes after I made that post :shrug:. Sometimes my thoughts are just slow to process.
By the way, what are you writing in C?
Nothing at the moment. Its more of a hobby/interest than anything else. Back in college I took C++ and really liked it but thought it lacked a certain something. After the semester my professor gave me a book on C and I found it really interesting. Now, 7 years later, I'm getting back into programming as something to do while I am not at work or playing COH, lol.
_Slim_Shady_
06-15-2007, 05:50 PM
No worries. Seriously check out C#. It's my favorite language. You get the elegance of a C-like language with the convienence of a managed language. The stuff you'll be able to do Vista and DX10 will blow your mind.
TouGe
06-17-2007, 03:54 AM
:up:
Will do and thanks for your help.
celemine1Gig
06-17-2007, 11:40 AM
There is an option in the project properties where you can choose between compiling your code as "c" or as "c++" code. ;)
TouGe
06-19-2007, 05:25 AM
There is? Hmm, I didn't know that. Thanks for the heads-up. When I get VS re-installed next week--waiting for an RMA'd MB since I'll have to do a clean install then--I'll have a look.
Hello everyone. Can someone here tell me how to compile code in C using Visual Studio 2005? I've used VS to write and compile C++ code but this is the first time I've used it to write in C.
When I go to 'add new item' the only option I get in relation to C is 'C++ File (.cpp)'. Now correct me if I am wrong but don't I need '.c' for a file extension to compile a program in C? I tried to compile a short program in C using the 'C++ File(.cpp)' but all I got were errors.
Any suggestions?
http://img413.imageshack.us/img413/2725/addnewitemsr8.th.png (http://img413.imageshack.us/my.php?image=addnewitemsr8.png)
um you have a file allready you should choose add existing item and you can choose the c file, anyway those are just templates you can enter any name you want