2

嗨,我已经用 Visual c++ 编写了一个程序,无论出于何种原因,现在我需要在 turbo c++ 3.0 中运行/编译这个相同的程序。

我已经设法从某个来源获得了编译器,但是当我尝试编译我的代码时出现了很多错误。我已经注释掉了“#include stdafx.h”,为 ide 中的目录和库设置了适当的路径。这些是给我错误的行

#include <list> //Error unable to open include file list

using namespace std; //Declaration syntax error

typedef list<int> itemist; // , expected

bool setPlayerChar(char key); // Type name expected // Declaration missing ;

void generateItemList(piece market[9], itemlist &ilist) // ) expected

bool exit = false; // Undefined symbol 'bool' // statement missing ;
4

4 回答 4

5

几年前,当 Turbo C++ 3.0 是最先进的时,今天的很多 C++ 东西都不存在。没有 STL,没有<list>,没有命名空间,甚至没有类型bool(通常由宏 'BOOL' 模拟)。如果我没记错的话,它只是一个 16 位编译器,它为您提供了额外的“乐趣”int和指针算术。

快乐移植 ;-)

于 2011-09-07T19:20:27.120 回答
0

如果您需要为 DOS 构建程序,您可以尝试 Borland C++ 5.02。它是 Borland 的最后一个支持 DOS 的编译器,并且包含了一些预标准的 STL。

像这样的代码:

#include <list>

using namespace std;

typedef list<int> itemist;

应该可以用它编译。

于 2011-09-08T14:21:15.613 回答
0

如果你真的需要在 DOS 下运行你的应用程序并且机器至少是 80386,我建议使用DJGPP。它提供了最新的 GCC。然后,您的应用程序将在 x86 保护模式下运行。

于 2011-09-08T05:14:09.367 回答
0

你可以试试这些丑陋的技巧:

/* Check if the compiler is Borland Turbo C++ 3.0 or earlier */
#ifdef __BORLANDC__
#if (__BORLANDC__ <= 0x400)

#include <list.h>

typedef int bool;
#define true  (1)
#define false (0)

#else

#include <list>

#endif

等等,但可以考虑使用更新的编译器,例如 GCC 或 MSVC。

于 2011-09-07T20:23:43.293 回答