我正在尝试在Visual C ++ 6.0中编译一些旧代码。缺少DSW文件,因此我将所有代码添加到新工作区中。
我有a.cpp
如下
#include "vld.h"
#include "afx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include "b.h"
...
void function_1(char* string1)
{
char buf[2000];
strcpy_s(&buf[0], 2000, string1);
strcat_s(&buf[0], 2000, "_append");
...
}
还使用了其他功能,例如fopen_s, strncpy_s, strncat_s
中的a.cpp
。
b.h
是
#include <stdio.h>
#include <string.h>
char function_2(unsigned char * string2, int abc, int def)
{
char buf2[200];
sprintf_s(buf2, 200, "abcdef");
strcat_s(buf2, 200, "ghijkl");
}
尽管已经有stdio.h
和string.h
,我仍然会收到错误
'sprintf_s': undeclared identifier
'strcat_s': undeclared identifier
'strcpy_s': undeclared identifier
'fopen_s': undeclared identifier
'strncpy_s': undeclared identifier
'strncat_s': undeclared identifier
适用于a.cpp
和b.h
。
我遗漏了丢失的设置吗?为什么我会收到这些错误?
答案 0 :(得分:2)
_s版本功能已添加到Visual Studio 2005中。因此您需要使用更现代的Visual Studio版本。