gpt4 book ai didi

c++ - 可以在 g++ 4.7+ 中重新启用 `uint` 类型吗?

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

我有大量代码正试图从 g++ 版本 4.2.2 转换为 4.7.2。在 4.2.2 及之前的版本中,uint 似乎被定义为 unsigned int。我知道这不是标准的 C++ 东西,真正的人写 ISO 标准 C++,但我想知道是否有标志或某种方式让 g++ 在不修改所有源文件的情况下接受 uint .我可以更改 CPPFLAGS 或向 g++ 运行线添加一个开关吗?我的谷歌一无所获。我有一些来自不同工作组的源文件,我想接​​受他们的 uint 违规行为。

例如

#include <iostream>
#include <fstream>
#include <assert.h>
using namespace std;
int main(void) {
uint foo = 0xdeadbeef;
cout<<hex<<foo<<endl;
}

产量:

/tmp/rbroger1/gcc_update rbroger1 @ plxc25804 
% /usr/intel/pkgs/gcc/4.2.2/bin/g++ ~/tmp.cc && ./a.out
deadbeef
/tmp/rbroger1/gcc_update rbroger1 @ plxc25804
% /usr/intel/pkgs/gcc/4.7.2/bin/g++ ~/tmp.cc && ./a.out
/nfs/pdx/home/rbroger1/tmp.cc: In function 'int main()':
/nfs/pdx/home/rbroger1/tmp.cc:8:5: error: 'uint' was not declared in this scope
/nfs/pdx/home/rbroger1/tmp.cc:8:10: error: expected ';' before 'foo'
/nfs/pdx/home/rbroger1/tmp.cc:9:16: error: 'foo' was not declared in this scope

最佳答案

您可以向 g++ 添加一个 -include a_file_where_there_is_typedef_to_uint.h 标志

From the manual

-include file

Process file as if #include "file" appeared as the first line of the primary source file. However, the first directory searched for file is the preprocessor's working directory instead of the directory containing the main source file. If not found there, it is searched for in the remainder of the #include "..." search chain as normal.

If multiple -include options are given, the files are included in the order they appear on the command line.

关于c++ - 可以在 g++ 4.7+ 中重新启用 `uint` 类型吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14969024/

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