gpt4 book ai didi

c++ - 在 g++ 中编译 Windows C++ 程序

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:40:44 25 4
gpt4 key购买 nike

我正在尝试用 g++ 编译一个 Windows C++ 程序。这就是我得到的。

/usr/include/c++/4.4/backward/backward_warning.h:28:2: warning: #warning This file includes at least one deprecated or antiquated header which may be removed without further notice at a future date. Please use a non-deprecated interface with equivalent functionality instead. For a listing of replacement headers and interfaces, consult the file backward_warning.h. To disable this warning use -Wno-deprecated.
btree.cpp:1204: error: ‘_TCHAR’ has not been declared
btree.cpp: In function ‘int _tmain(int, int**)’:
btree.cpp:1218: error: ‘__int64’ was not declared in this scope
btree.cpp:1218: error: expected ‘;’ before ‘frequency’
btree.cpp:1220: error: ‘LARGE_INTEGER’ was not declared in this scope
btree.cpp:1220: error: expected primary-expression before ‘)’ token
btree.cpp:1220: error: ‘frequency’ was not declared in this scope
btree.cpp:1220: error: ‘QueryPerformanceFrequency’ was not declared in this scope
btree.cpp:1262: error: expected primary-expression before ‘)’ token
btree.cpp:1262: error: ‘start’ was not declared in this scope
btree.cpp:1262: error: ‘QueryPerformanceCounter’ was not declared in this scope
btree.cpp:1264: error: name lookup of ‘i’ changed for ISO ‘for’ scoping
btree.cpp:1264: note: (if you use ‘-fpermissive’ G++ will accept your code)
btree.cpp:1304: error: expected primary-expression before ‘)’ token
btree.cpp:1304: error: ‘end’ was not declared in this scope
btree.cpp:1306: error: ‘total’ was not declared in this scope
btree.cpp:1316: error: ‘getchar’ was not declared in this scope

我首先注意到的是这些变量类型称为 _TCHAR、_int64 和 LARGE_INTEGER,这可能是 Windows 的东西。可以将它们更改为什么以便它们可以在 g++ 中工作?

此外,如果您知道此处还有其他任何内容可以转换为 g++,那将很有帮助。

我从这里得到代码: http://touc.org/btree.html

最佳答案

来自链接页面:

  // the main function is just some code to test the b-tree.  it inserts 100,000 elements,
// then searches for each of them, then deletes them in reverse order (also tested in
// forward order) and searches for all 100,000 elements after each deletion to ensure that
// all remaining elements remain accessible.

如果你完全放弃 _tmain,你应该可以开始了。 __int64LARGE_INTEGER 仅用于调用 QueryPerformanceCounter,并且只能从测试主函数调用。看起来代码在其他方面是相对可移植的 C++,而且实际上看起来错误只是真正从 _tmain 开始。

关于c++ - 在 g++ 中编译 Windows C++ 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2792604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com