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>

相关推荐
曹牧4 分钟前
C#:注释嵌套
开发语言·c#
中国搜索直付通8 分钟前
游戏车机端支付通道,会是下一个被低估的合规战场吗?
java·大数据·开发语言·人工智能·游戏
LccKyI13 分钟前
C# 零基础学习 Day01|基础概念梳理 + 思维导图总结
开发语言·笔记·学习·c#
AKA__Zas17 分钟前
芝士算法(位运算)
java·开发语言·算法·leetcode·学习方法
Livia要学习26 分钟前
Python三种常见高阶函数--map、filter、sorted
开发语言·python
奇树谦1 小时前
ZeroMQ 详解:轻量级高性能消息通信框架及 C++ 使用示例
开发语言·c++
不相心 -w-1 小时前
现代C++——智能指针
开发语言·c++
爱和冰阔落1 小时前
【Linux】从匿名管道到进程池:任务派发、fd 继承 Bug 与完整实现
android·linux·运维·c++
Ivanqhz1 小时前
php7 闭包实现
开发语言·后端·rust·php
TunerT_TQ1 小时前
Valhalla 静态工程审阅 #021|华为MindSpore 源码证据驱动评测【大厂开源基础设施特辑】
c++·开源·github·mfc·#大模型开源·#华为开源·#深度学习