在构建MSDN示例时使用多字节字符集,我们得到最后一行的“初始化程序不是常量”错误。 VS10 SP1,没有CLR。
#define arraysize 30
TCHAR pszDest[arraysize];
size_t cbDest = arraysize * sizeof(TCHAR);
LPCTSTR pszFormat = TEXT("%s %d + %d = %d.");
TCHAR* pszTxt = TEXT("The answer is");
HRESULT hr = StringCbPrintf(pszDest, cbDest, pszFormat, pszTxt, 1, 2, 3);
// The resultant string at pszDest is "The answer is 1 + 2 = 3."
其他CLR选项失败。无论如何要删除错误?
答案 0 :(得分:0)
基于C的代码(即Hans'评论)可以在VS Win32项目中运行。模块范围的声明是:
@interface MyGestureDelegate : NSObject <UIGestureRecognizerDelegate>
@end
@implementation MyGestureDelegate
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
return YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer{
return YES;
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
return YES;
}
代码已插入_tWinMain程序:
#include <windows.h>
#include "stdafx.h"
#include <Strsafe.h>
#include <stdio.h>
#include "msgbox.h"
int hr = 0;
#define arraysize 30
wchar_t hrtext[128];
HWND hWnd;