0

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_sinなどの他の関数も使用さ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.hstring.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

省略した設定がありませんか?なぜこれらのエラーが発生するのですか?

4

1 に答える 1

2

_s version 関数は Visual Studio 2005 に追加されました。そのため、最新の Visual Studio バージョンを使用する必要があります。

于 2013-01-07T04:13:16.400 に答える