I've downloaded a new copy of visual C++ express last night and would like to know how to compile simple cpp files that are not part of a project. Maybe this makes me retarded but I would like to use this program as my main programing medium.
I think you can do File > Open to select a .cpp (or .h etc), then compile it from there using Debug > Start debugging. "Think" being the operative word. Try it!
zachlr: I think you maybe right, but this should generate an object file. Not an executable. The only reason I can see for doing this is to manually link the object file into your application. But having it as part of a project does this anyway.
If they were trying to compile into an executable then they'd have to compile and link. I dunno how VC++ does the linking, I am familiar with GCC's implementation.
What I do is make one blank project(mines called "Practice) and add "New item" to source files. Than when I'm done, I debug/compile. If I'm done with that .cpp, I save it if I want to use it for later use, if not, I just delete everything in the item and do another file. This is on VC++ 2008 as well.
You're right Zatia, I just tried making a .cpp to test it with, and regardless of the open tabs, it will try to debug the whole project. When I close the program and reopen it and File > Open the test.cpp, all of the debugging options are disabled, and Compile is not there.
You would think you would be able to just compile a single .cpp with it. Guess not.
I would just do like Dirtrider said. The only problem there is if you are working on a few standalone .cpp's, when you try to compile one, it will compile all of them, some of which may still be in progress and have errors.
You could also try Zatia's way. It sounds kind of advanced, I don't understand it myself, but he sounds like he knows what he's talking about.
Other than that I'm not sure, you may end up just having to make a new project each time.
Yea I had figured as much :) I use Visual Studio for C# and it's the same thing. You have to have a proj/solution before you can compile anything.
It makes sense because it's a way for the IDE to inform the compiler of all resources it needs to compile. Once the compliation is done it will call a link to link the object files together into a single executable.
With just 1 CPP file it's possible to compile it into an object then just link it by itself. But most IDEs work in project space so don't understand this outside of a project.
You should, for good practice, always create a project around whatever you are developing. Even if the project is called "test" where you copy and paste code just to try things (as I do from this forum). Also a good idea to not delete your work, as building a good personal library of code is going to beneficial for you in the future.