我已被要求添加功能到現有的舊項目,但我無法讓它建立。 它處理unicode字符串,但我得到了很多有關使用TCHAR的錯誤。特別是幾乎每個錯誤都是TCHAR無法轉換爲或用作wchar_t。 從我在許多不同的文章中看到的,我嘗試使用#define _UNICODE或#define UNICODE,但沒有人解決了這個問題。使用TCHAR的錯誤,無法轉換爲wchar_t
這裏是一塊代碼的:
#include <windows.h>
#include <wininet.h>
#include <tchar.h>
#include <iostream>
#include <fstream>
#include <strsafe.h>
#include <string>
#include <list>
#include <cctype>
#include <winnt.h>
#include <atlconv.h>
#pragma comment(lib,"wininet.lib")
using namespace std;
TCHAR *tags[] = { _T("aa"), _T("bb"), _T("cc"),
NULL };
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0;
for (i = 1; i<argc; i++) {
if (wcscmp(argv[i], _T("-h")) == 0) {
...
}
else if (wcscmp(argv[i], _T("-f")) == 0) {
...
}
...
}
在上述線例如使用wcscmp時,我得到
argument of type "_TCHAR *" is incompatible with parameter of type "const wchar_t *"
關於argv的
[I]
和
argument of type "const char *" is incompatible with parameter of type "const wchar_t *"
regar ding _T(「 - h」)。
任何建議將非常感激。
非常好的答案!我真的想知道這種編碼實際上是否有必要。感謝大衛! – yiannis