开发者社区> 问答> 正文

编译qtopia2.2.0报错:“没有声明任何东西”?报错

初学linux QT编程,结果花了好几天来搭建编译环境。好多问题都多少能理解一点,网上多少也能搜到一些资料。但下面这个问题,完全不知道怎么入手了。希望大牛门多多指点qtopedora

错误如下:
In file included from ../../../include/qtopia/applnk.h:1:0,
from editor/imageio.h:39,
from editor/imageio.cpp:36:
../../../include/qtopia/../../src/libraries/qtopia/applnk.h: 在成员函数‘const QList<DocLnk>& DocLnkSet::children() const’中:
../../../include/qtopia/../../src/libraries/qtopia/applnk.h:211:75: 警告:提领类
型双关的指针将破坏强重叠规则 [-Wstrict-aliasing]
In file included from /usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/cstring:43:0,
from editor/imageio.cpp:38:
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/x86_64-redhat-linux/32/bits/c++config.h: 在全局域:
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/x86_64-redhat-linux/32/bits/c++config.h:174:15: 错误:没有声明任何东西 [-fpermissive]

在谷歌,百度各种搜索都没有相关内容。
头文件c++config.h中174行附近的代码如下:
171 namespace std
172 {
173 typedef __SIZE_TYPE__ size_t;
174 typedef __PTRDIFF_TYPE__ ptrdiff_t;
175 #ifdef __GXX_EXPERIMENTAL_CXX0X__
176 typedef decltype(nullptr) nullptr_t;
177 #endif
178 }

实在没有找到解决的办法,define和typedef的功能有些时候差不多,于是将174还改成了

#define ptrdiff_t __PTRDIFF_TYPE__
然后这段编译过了但之后又编译了意外的问题:
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ext/new_allocator.h:43:14: 错误:expected unqualified-id before ‘long’
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ext/new_allocator.h:43:14: 错误:expected ‘;’ before ‘long’
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ext/new_allocator.h:43:19: 错误:没有声明任何东西 [-fpermissive]
new_allocator.h的43还附近的代码如下:
41
42 using std::size_t;
43 using std::ptrdiff_t;
44

同样,在网上没有搜到相关资料。但发现包含有头文件
33 #include <bits/c++config.h>
会不会是之前修改的那部分导致的。于是有把c++config.h给修改回来了。
编译居然完全通过了!

正在庆幸搞了几天终于把环境搭建起来了,如是照着书写了一个Hello World的程序,编译还是没通过,提示错误如下:
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ext/new_allocator.h:43:14: 错误:expected unqualified-id before ‘long’
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ext/new_allocator.h:43:14: 错误:expected ‘;’ before ‘long’
/usr/lib/gcc/x86_64-redhat-linux/4.7.2/../../../../include/c++/4.7.2/ext/new_allocator.h:43:19: 错误:没有声明任何东西 [-fpermissive]
肯定是修改c++config.h造成的

现在又重新编译呗,一切还是回到了原点:还是没逃过最初的那个错误。。。。。。。
有没有哪位大牛知道这是怎么回事阿。求指教。


展开
收起
爱吃鱼的程序员 2020-06-22 14:29:26 479 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    Qtopia好老的東西了…可能和你比較新的GCC不兼容...谢谢,现在看的视频教程确实有点老了

    2020-06-22 14:29:42
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载