MS precompiled headers
After Elysia's remarks giving me at least some idea of the reasoning behind these precompiled headers, I just started exploring these a little and have some questions.
First, VS also creates a file called targetver.h, which contains simply this:
I'm running this on an XP computer, and VS didn't put #include "targetver.h" into the file containing main. How does this file work? Do I need to put #include "targetver.h" in main in order to activate the macros that this file is somehow calling up?
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
Second, rather than the int main() that I have been using, VS supplies:
int _tmain(int argc, _TCHAR* argv)
Just to see how (that) it works, I ran a "Hello, World" from there, and it worked fine. I'm just wondering what the parameters are doing here. It looks like it's giving you the opportunity to pass an int and an array of pointers to C-strings into main if you need to ... (?)
one other thing on the targetver.h issue: What do I put in there to specify XP as the minimum platform? I'm not finding it in VS help anyway.
I believe the arguments are for command-line arguments, and the integer holds the number of arguments, and the character arrays hold you arguments themselves, but I'm not sure.
that makes sense. It looks a lot like Java's command line arguments.
It's included by stdafx.h I believe, which will be included in main.
Originally Posted by Aisthesis
The targetver.h file usually contains some code that allows you to target specific versions of the Windows platform. Searching for the name of the macro (ie _WINNT32_WINNT) might help you find some info on what to add or change to change what platform you target.
As for the _tmain, it is basically a macro that changes the function name depending on if you unicode or multi-byte. If you multi-byte, it becomes main; otherwise it becomes wmain.
The same with _TCHAR. It translates to char or wchar_t depending on if you are using Unicode or not.