0

I want to know what is difference between empty and not empty( the stdafx file added) projects in visual studio. What is in stdafx.cpp/h files?

Why in that file defined _tmain() not main() ?

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

In old books i find code like this`

int WINAPI _tWinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int),

Where i should write that code to force it work?

(sorry for bad english ))) )

user777
  • 19
  • 3

2 Answers2

2

A lot of questions for one question.

1.) There is no real different between a empty project and a non empty project. As far as I know, precompiled headers are off in empty projects. 2.) stdafx.h is used by microsoft for the standard includes. It also acts as the single include for precompiled headers. If you use precompiled headers, you have to include stdafx.h. The details for that I explained here: https://stackoverflow.com/a/18685377/1922748

3.) By default, Microsoft uses UNICODE strings, they use 16bit instead of 8bit. A char is always 8bit, So microsoft defined macros for that. If you compile it (see the settings page) with _UNICODE the macro is

#define THCAR short

with "multiple bytes" it is

#define TCHAR char

the same is with main and _tmain

4.) It is not old books, it is different projects.

_tWinMain

is the entrypoint for window based application like the browser you are using.

_tmain

is the entrypoint for console applications.

Community
  • 1
  • 1
Martin Schlott
  • 4,369
  • 3
  • 25
  • 49
2
  1. Empty projects have no automatically written source or header files in. The other "non-empty" projects generate some skeletal code for you automatically - try and see what you get.
  2. stdafx files are precompiled - details here
  3. The _t prefix maps to the type of character encoding you are using. It is a microsoft extension. See here Essentially it switches between wmain for unicode versus main otherwise.
Community
  • 1
  • 1
doctorlove
  • 18,872
  • 2
  • 46
  • 62