gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 上编译问题笔记

编译错误如下:

In file included from /usr/include/glib-2.0/glib/glib-typeof.h:39,

from /usr/include/glib-2.0/glib/gatomic.h:28,

from /usr/include/glib-2.0/glib/gthread.h:32,

from /usr/include/glib-2.0/glib/gasyncqueue.h:32,

from /usr/include/glib-2.0/glib.h:32,

from ../libqemu/qemu-common.h:39,

from ../libqemu/qemu-aio.h:17,

from ../libqemu/block.h:4,

from ../libqemu/block_int.h:27,

from Block.h:6,

from Block.cpp:1:

/usr/include/c++/11/type_traits:1006:3: error: template with C linkage

1006 | template<typename _Tp>

| ^~~~~~~~

In file included from Block.cpp:1:

Block.h:4:1: note: 'extern "C"' linkage started here

4 | extern "C"

| ^~~~~~~~~~

In file included from /usr/include/glib-2.0/glib/glib-typeof.h:39,

from /usr/include/glib-2.0/glib/gatomic.h:28,

from /usr/include/glib-2.0/glib/gthread.h:32,

from /usr/include/glib-2.0/glib/gasyncqueue.h:32,

from /usr/include/glib-2.0/glib.h:32,

from ../libqemu/qemu-common.h:39,

from ../libqemu/qemu-aio.h:17,

from ../libqemu/block.h:4,

from ../libqemu/block_int.h:27,

from Block.h:6,

from Block.cpp:1:

/usr/include/c++/11/type_traits:1015:3: error: template with C linkage

1015 | template<typename _Tp, typename... _Args>

| ^~~~~~~~

In file included from Block.cpp:1:

Block.h:4:1: note: 'extern "C"' linkage started here

4 | extern "C"

| ^~~~~~~~~~

In file included from /usr/include/glib-2.0/glib/glib-typeof.h:39,

from /usr/include/glib-2.0/glib/gatomic.h:28,

from /usr/include/glib-2.0/glib/gthread.h:32,

from /usr/include/glib-2.0/glib/gasyncqueue.h:32,

from /usr/include/glib-2.0/glib.h:32,

from ../libqemu/qemu-common.h:39,

from ../libqemu/qemu-aio.h:17,

from ../libqemu/block.h:4,

from ../libqemu/block_int.h:27,

from Block.h:6,

from Block.cpp:1:

/usr/include/c++/11/type_traits:1021:3: error: template with C linkage

1021 | template<typename _Tp, typename... _Args>

| ^~~~~~~~

In file included from Block.cpp:1:

解决方法:

修改了Block.cpp,在其#include "Block.h"之前添加 #include <glib.h>

相关推荐
尘浮72818 分钟前
60天python训练计划----day59
开发语言·python
Chef_Chen1 小时前
从0开始学习R语言--Day39--Spearman 秩相关
开发语言·学习·r语言
不学会Ⅳ1 小时前
Mac M芯片搭建jdk源码环境(jdk24)
java·开发语言·macos
2401_881244401 小时前
牛客周赛99
c++
好开心啊没烦恼2 小时前
Python 数据分析:计算,分组统计1,df.groupby()。听故事学知识点怎么这么容易?
开发语言·python·数据挖掘·数据分析·pandas
lljss20203 小时前
Python11中创建虚拟环境、安装 TensorFlow
开发语言·python·tensorflow
山登绝顶我为峰 3(^v^)34 小时前
如何录制带备注的演示文稿(LaTex Beamer + Pympress)
c++·线性代数·算法·计算机·密码学·音视频·latex
Python×CATIA工业智造6 小时前
Frida RPC高级应用:动态模拟执行Android so文件实战指南
开发语言·python·pycharm
十五年专注C++开发6 小时前
CMake基础:条件判断详解
c++·跨平台·cmake·自动化编译
我叫小白菜7 小时前
【Java_EE】单例模式、阻塞队列、线程池、定时器
java·开发语言