230628-expected unqualified-id

eton@230628 在编译supra基于debian12 Qt5.15 tbb12 libtbb12/stable,now 2021.8.0-2 amd64 的时候遇到下面的问题。 一直找不到实际的问题原因,指导发现下面几个github的链接,原来是符号冲突导致的。

1. resolve solution

1. 添加QT_NO_KEYWORDS到编译选项中;

TARGET_COMPILE_DEFINITIONS(SUPRA_GUI
PRIVATE ${SUPRA_Lib_DEFINES}
${CAMPVIS_DEFINITIONS} NODE_EDITOR_STATIC QT_NO_KEYWORDS)

ref:

2. 将qt中的关键字替换为宏定义

signal: 替换为Q_SIGNALS

slots: 替换为Q_SLOTS

emit 替换为Q_EMIT

因为上面的内容

It tells Qt not to define the moc keywords signals, slots, and emit, because these names will be used by a 3rd party library, e.g. Boost. Then to continue using Qt signals and slots with the no_keywords flag, simply replace all uses of the Qt moc keywords in your sources with the corresponding Qt macros Q_SIGNALS (or Q_SIGNAL), Q_SLOTS (or Q_SLOT), and Q_EMIT.

ref:

3. 重新编译,因为supra中涉及到使用第三方库NodeEdit,这个也使用了Qt所以也需要做setp02的替换。

for i in `find  ./ -name "*.hpp"` ; do
sed s/signals:/Q_SIGNALS:/g -i $i && \
sed s/slots:/Q_SLOTS:/g -i $i && \
sed s/emit:/Q_EMIT:/g -i $i;
done

2. process step

1. g++ -E /usr/include/oneapi/tbb/flow_graph.h > a.h 查看实际生成的文件到底是否存在语法问题;

合并头文件得到的问题代码截取部分如下,其实可以看到是没有语法问题的。

namespace d1 {
# 190 "/usr/include/oneapi/tbb/profiling.h"
inline void create_itt_sync(void* , const char* , const char* ) {} inline void call_itt_notify(notify_type , void* ) {} inline void call_itt_task_notify(notify_type , void* ) {}
# 226 "/usr/include/oneapi/tbb/profiling.h"
struct event {
event(const std::string &) { } void emit() { } static void emit(const std::string &) { }
};
}

但是这里学习到了namespace的注入功能

# 20 "/usr/include/oneapi/tbb/detail/_namespace_injection.h"
namespace tbb {} namespace oneapi {
namespace tbb = ::tbb;
}

目标是将::tbb等价于::oneapi::tbb 这样就可以兼容以前没有oneapi时候对tbb的命名空间的使用了.

ref:

2. 分析C++中到底'qualified'是什么意思

A qualified id-expression is an unqualified id-expression prepended by a scope resolution operator ::, and optionally, a sequence of any of the following separated by scope resolution operators

有人做如下翻译,这样理解相对容易

非受限id(Unqualified-id)

广义化的标识符(identifier)。它可以是前面的任何一种或者析构函数的名称(比如Date或者List<T, T, N>)

受限id(qualified-id)

用一个类名或者名字空间对一个unqualified-id进行限定,或者使用全局作用域解析运算符::进行限定

这种名称可以是多次限定的

例子:::X,S::x,Array::y,::N::A:

ref: https://en.cppreference.com/w/cpp/language/qualified_lookup

3. search below info in bing.

oneapi/tbb/profiling.h:229:15: error: expected unqualified-id before ‘)’ token

get the resolution finally.

error message:

/usr/include/oneapi/tbb/profiling.h:229:15: error: expected unqualified-id before ‘)’ token

229 | void emit() { }

| ^

/usr/include/oneapi/tbb/profiling.h:231:22: error: expected unqualified-id before ‘const’

231 | static void emit(const std::string &) { }

| ^~~~~

/usr/include/oneapi/tbb/profiling.h:231:22: error: expected ‘)’ before ‘const’

231 | static void emit(const std::string &) { }

| ^~~~

| )


3. 当前问题产生的实际分析

  1. Qt代码中signals, slots, emit其实都是宏定义的关键字, "qobjectdefs.h" 中对与signals, slots, emit的解析最后都是empty,也就是最后macro在解析的时候如果遇到emit这个字符串,那么如果前面存在Qt的头引用,那么就会出现

    # define emit

    这样后面emit关键字变为‘NULL’这样就不符合C++的语法了,因为函数定义需要一个NAME ;

  2. Recurrence issues

    创建如下文件:

$ cat abc.cc
void fun(){}
void emit(){}
void fun3(){}

利用g++ -c进行编译

$ g++ -Demit='' -c  abc.cc
abc.cc:2:11: error: expected unqualified-id before ‘)’ token
2 | void emit(){}
| ^
  1. 问题完整的复现,finish.

Appendix

full error log.

FAILED: src/GraphicInterface/CMakeFiles/SUPRA_GUI.dir/SUPRA_GUI_autogen/mocs_compilation.cpp.o
/usr/bin/g++ -DHAVE_BEAMFORMER -DHAVE_BEAMFORMER_MINIMUM_VARIANCE -DHAVE_CUDA -DHAVE_CUDA_CUBLAS -DHAVE_CUFFT -DHAVE_DEVICE_IGTL_OUTPUT -DHAVE_DEVICE_METAIMAGE_OUTPUT -DHAVE_DEVICE_TRACKING_IGTL -DHAVE_DEVICE_TRACKING_SIM -DHAVE_DEVICE_ULTRASOUND_SIM -DNODE_EDITOR_STATIC -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I/home/eton/00-src/build-supra-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/GraphicInterface -I/home/eton/00-src/supra/src/GraphicInterface -I/home/eton/00-src/build-supra-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/GraphicInterface/SUPRA_GUI_autogen/include -I/home/eton/00-src/supra/src/GraphicInterface/SUPRA_GUI -I/home/eton/00-src/build-supra-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/GraphicInterface/NodeEditor_install/include -I/home/eton/00-src/build-supra-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/GraphicInterface/NodeEditor/include -I/home/eton/00-src/supra/src/GraphicInterface/private -I/include -I/home/eton/00-src/supra/src/SupraLib -I/home/eton/00-src/supra/src/SupraLib/utilities/jsoncpp -I/usr/include/openigtlink -isystem /home/eton/Qt/5.15.2/gcc_64/include -isystem /home/eton/Qt/5.15.2/gcc_64/include/QtWidgets -isystem /home/eton/Qt/5.15.2/gcc_64/include/QtGui -isystem /home/eton/Qt/5.15.2/gcc_64/include/QtCore -isystem /home/eton/Qt/5.15.2/gcc_64/./mkspecs/linux-g++ -DQT_QML_DEBUG -fopenmp -g -fPIC -std=gnu++11 -MD -MT src/GraphicInterface/CMakeFiles/SUPRA_GUI.dir/SUPRA_GUI_autogen/mocs_compilation.cpp.o -MF src/GraphicInterface/CMakeFiles/SUPRA_GUI.dir/SUPRA_GUI_autogen/mocs_compilation.cpp.o.d -o src/GraphicInterface/CMakeFiles/SUPRA_GUI.dir/SUPRA_GUI_autogen/mocs_compilation.cpp.o -c /home/eton/00-src/build-supra-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/GraphicInterface/SUPRA_GUI_autogen/mocs_compilation.cpp
In file included from /usr/include/oneapi/tbb/spin_mutex.h:23,
from /usr/include/oneapi/tbb/flow_graph.h:26,
from /usr/include/tbb/flow_graph.h:17,
from /home/eton/00-src/supra/src/SupraLib/SupraManager.h:21,
from /home/eton/00-src/build-supra-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/GraphicInterface/SUPRA_GUI_autogen/EWIEGA46WW/../../../../../supra/src/GraphicInterface/parameterWidget.h:3,
from /home/eton/00-src/build-supra-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/GraphicInterface/SUPRA_GUI_autogen/EWIEGA46WW/moc_parameterWidget.cpp:10,
from /home/eton/00-src/build-supra-Desktop_Qt_5_15_2_GCC_64bit-Debug/src/GraphicInterface/SUPRA_GUI_autogen/mocs_compilation.cpp:6:
/usr/include/oneapi/tbb/profiling.h:229:15: error: expected unqualified-id before ‘)’ token
229 | void emit() { }
| ^
/usr/include/oneapi/tbb/profiling.h:231:22: error: expected unqualified-id before ‘const’
231 | static void emit(const std::string &) { }
| ^~~~~
/usr/include/oneapi/tbb/profiling.h:231:22: error: expected ‘)’ before ‘const’
231 | static void emit(const std::string &) { }
| ~^~~~~
| )

end./

expected unqualified-id on oneapi tbb12的更多相关文章

  1. xcode构建webdriverAgent时报错Messaging unqualified id的解决办法

    在使用xcode构建webdriverAgent时,提示build failed,报错信息为:semantic issue:Messaging unqualified id,可以参考以下解决方案 xc ...

  2. Thrift Expected protocol id ffffff82 but got 0

    如果服务端配的也是noblock=false;客户端不能改成noblock=true;

  3. Statement returned more than one row, where no more than one was expected

    Statement returned more than one row, where no more than one was expected <resultMap id="Stu ...

  4. 【jQuery EasyUI系列】使用属性介绍

    1.ValidateBox The validatebox is designed to validate the form input fields.If users enter invalid v ...

  5. Quartus II Error总结与解答

    (1).Error (209015): Can't configure device. Expected JTAG ID code 0x020B20DD for device 1, but found ...

  6. XSD标准架构-----<xsd:element> 元素详解

    声明一个元素.     <element abstract = Boolean : false block = (#all | List of (extension | restriction ...

  7. 学习selenium python版最初的一个小想法

    这个还是我在刚开始学习selenium的时候做的,自己觉得有点意思,在接下来我会基于目前我对于selenium的一些深入研究,写下我对selenium的理解以及UIAutomation的一些理解,以此 ...

  8. Java与C之间的socket通信

    最近正在开发一个基于指纹的音乐检索应用,算法部分已经完成,所以尝试做一个Android App.Android与服务器通信通常采用HTTP通信方式和Socket通信方式.由于对web服务器编程了解较少 ...

  9. ubuntu1604 golang环境

    copy来的,这里记录一下 1. 升级系统: sudo apt-get upgrade 2. 安装docker 下载docker-ce: https://download.docker.com/lin ...

  10. [Oracle][RMAN] Use RMAN to Migrate database from CentOS_5-11201-SingleDB to OracleLinux_5-11204-SingleDB

    リンク:How to Move/Restore DB to New Host and File System using RMAN (Doc ID 1338193.1)https://docs.ora ...

随机推荐

  1. 有一个公网IP地址

    这几天在家里拉了一条300M+的宽带,但是遇到了一些坑,本文就简单说明一下如下: 突发此次需求是这样的:阿里云有台服务器公网带宽是1M的,虽说带宽小,但是数据中心的服务器显然是稳定的,只是带宽太小,有 ...

  2. 浅析Nordic nRF5 SDK例程架构

    很多刚接触Nordic nRF5 SDK的初学者出于对新平台的不熟悉,会觉得这个SDK很难,本文讲浅析nRF5 SDK中例程的架构,让初学者能够快速上手SDK. 在开始之前,先推荐阅读观看下面这些文章 ...

  3. JQuery点击复制文本框内容的方法插件

    [导读] 文章介绍了两种常用的点击复制文本框内容方法,一种是but IE only,同样的这个也是我们经常使用的.优点是体积小,仅有十来行代码,但缺点也很明显,只支持IE及以IE为内核的浏览器,另一种 ...

  4. 23.oneOf

    const { resolve } = require('path') const HtmlWebpackPlugin = require('html-webpack-plugin') // 提取cs ...

  5. Midjourney 提示词工具(10 个国内外最好最推荐的)

    Midjourney,是一个革命性的基于人工智能的艺术生成器,可以从被称为提示的简单文本描述中生成令人惊叹的图像.Midjourney已经迅速成为艺术家.设计师和营销人员的首选工具(包括像我这样根本不 ...

  6. 基于QtAV的简易播放器(开源)

    这个开源代码,是我利用QtAV源码,提取其中一部分代码,进行整合到我自己项目中,做的一个小型播放器测试,至于怎么安装一些环境以及QtAV源码编译在我以前写的一篇博客中可以看到(Qt第三方库QtAV-- ...

  7. springcloud~Sentinel

    介绍 随着微服务的流行,服务和服务之间的稳定性变得越来越重要.Sentinel 是面向分布式.多语言异构化服务架构的流量治理组件,主要以流量为切入点,从流量路由.流量控制.流量整形.熔断降级.系统自适 ...

  8. 2023-04-21:用go语言重写ffmpeg的metadata.c示例。

    2023-04-21:用go语言重写ffmpeg的metadata.c示例. 答案2023-04-21: 这段 Go 代码演示了如何使用 ffmpeg-go 库中的函数来读取多媒体文件元数据,包括视频 ...

  9. 2023-03-30:用Go语言改写FFmpeg示例decode_audio.c,实现高效音频解码。

    2023-03-30:用Go语言改写FFmpeg示例decode_audio.c,实现高效音频解码. 答案2023-03-30: 这个程序的主要功能是将 MP2 音频文件解码为 PCM 格式,并输出到 ...

  10. 2022-11-19:第二高的薪水。表结构和数据的sql语句如下,输出200,因为200是第二大的。请问sql语句如何写? DROP TABLE IF EXISTS `employee`; CREAT

    2022-11-19:第二高的薪水.表结构和数据的sql语句如下,输出200,因为200是第二大的.请问sql语句如何写? DROP TABLE IF EXISTS `employee`; CREAT ...