_tmain VS. main (1)

// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
 wcout<< argc<<endl;
 wcout<< argv[0]<< endl;
 system("pause");
 return 0;
}
 
the same as to:
// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
 cout<< argc<<endl;
 cout<< argv[0]<< endl;
 system("pause");
 return 0;
}
 
BUT:
// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
 cout<< argc<<endl;
 cout<< argv[0]<< endl;
 system("pause");
 return 0;
}
 
MS使用_t前缀的函数目的就在于期望使用一种统一写法可以方便地在宽字符版本和窄字符版本函数间快速地替换。
对于ANSI版本,"_tWinMain"就是"WinMain";对于UINCODE版本,"_tWinMain"就是"wWinMain"。  
  (比如这样的定义:)  
  #ifdef   _UNICODE  
  #define   _tmain   wmain  
  #define   _tWinMain   wWinMain  
  #else  
  #define   _tmain   main  
  #define   _tWinMain   WinMain  
  #endif  
VS 2008 default: Unicode
 
Q:Why UNICODE?
A:"Universal Multiple-Octet Coded Character Set"
在unicode语言环境下,不会再有语言的编码冲突,同屏可以显示任何语言,这就是Unicode的最大好处。
 
Message Box实现多语言即时翻译?

3 responses to “_tmain VS. main (1)

  1. Hao

    Thanks for sharing…前几天装了个vs2010,遇到貌似也是入口点的问题,怎么也搞不定。最后装回2005。

  2. Sauce

    看到这个,又有看本书的欲望了,Windows核心编程

  3. firefly

    solution:在你建立的解决方案的工程文件的属性看到选"配置属性"的"字符集"选择"使用多字节字符集"就可以了。 2005打开6.0的文件时候不会出现的这样的错误,是因为编译环境在转换过程中进行了转换.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

John's Weblog

Just another WordPress.com weblog

I Am That I Am

Chasing tomorrow's sunrise.

%d bloggers like this: