Visual Studio 2013 Question

I finally got around to downloading, installing, and playing with Visual Studio 2013, specifically, the Express Edition for Windows Desktop (for C++).

Every time I upgrade, it seems like I have to re-learn the GUI.

As my first test, I took an existing program that worked in a previous version of VS Express and tried to make it work in VS2013.

A couple things got me puzzled.

1) Experiment 1: Created a Win32 Console Application with the New Project Wizard. Worked pretty much as in the tutorial elsewhere in these forums (http://www.cplusplus.com/doc/tutorial/introduction/visualstudio/). One difference between the tutorial and VS2013 is that in VS2013, a basic .cpp source file is automatically created in the new project; you don't have to manually add it to the project. This source file looks like the following:

1
2
3
4
5
6
7
8
9
10
11
// Source1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}


I deleted this content and replaced it with my own source code, but got an error when trying to compile, stating that I must include "stdafx.h". So I added it back into my source file. It compiles and runs fine now.

I don't recall ever needing to include this file in any of my previous programs. Anybody here know why the change? (Perhaps is was always there, but included behind the scenes?) If I go back and port all my existing code to VS2013, I'd rather not have to add this line to all my programs. Anybody here know how to remove it from my source code file, but ensure the program runs correctly?

2) Experiment 2: I created another project, an "Empty Project" with the New Project Wizard. Copied the same source code into this project. This time I cannot compile. An error message pops up saying, "Unable to start program. . . .The system cannot find the file." I am sure I am overlooking something simple, and will kick myself later for it, but it is eluding me for now. What do I have to do to make this program compile and run?
Michael37 wrote:
I deleted this content and replaced it with my own source code, but got an error when trying to compile, stating that I must include "stdafx.h". So I added it back into my source file. It compiles and runs fine now.
As with every version of Visual Studio, the templates they try to force upon you default to using a precompiled header. Always go out of your way to make sure you start a new, blank project, with no existing source or header files.

In Experiment 2, how did you add in the source file? Were there any error messages that got ignored and it tried to run what would have been the generated executable?
Last edited on
Hi, "LB".

Thanks for the reply.

I deleted those two experimental projects and started over from scratch. In retracing my steps, I think I discovered my error (I knew I'd kick myself for this.)

I did create a completely empty Project, and selected Visual C++ (see following image).

http://i.imgur.com/lkBtEuJ.png

After clicking "OK", was returned to a completely empty project.

However, I think I went wrong by going through the FILE menu:
FILE->"New File..." (see following image).

http://i.imgur.com/OZzkoAl.png

I think what I should have done was go through the "PROJECT" menu and select "Add New Item ..." (see following image).

http://i.imgur.com/WClETdz.png

So, my mistake was to create a file but not add it to the project.

Things seem to be working as normal now.

I am curious though: the "stdafx.h" file that I mentioned in my first post: what is the point of it? My console program seems to behave the same whether it is there or not. What is the point of that small code block that is automatically added to a program when a person selects Create New Console Project?
I am curious though: the "stdafx.h" file that I mentioned in my first post: what is the point of it?


Hello, google.
http://en.wikipedia.org/wiki/Precompiled_header

The setting is here:
http://s2.postimg.org/vt5b27j15/afx.png


I will observe that all of the issues you say you ran into here are also issues in previous versions of the IDE, so I'm not sure why you had a problem dealing with them when you upgraded to the latest version.

Ah, yeah, I usually right click in the project tree and add items from there.
Topic archived. No new replies allowed.