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>

相关推荐
Dovis(誓平步青云)1 分钟前
解构C++高级命名空间:构建空间作用域·控制兼容
开发语言·c++·经验分享·笔记·学习方法
Tummer83637 分钟前
C语言与C++的区别
c语言·c++·算法
一只蒟蒻ovo25 分钟前
操作系统导论——第26章 并发:介绍
java·开发语言
2301_807611491 小时前
47. 全排列 II
c++·算法·leetcode·回溯
✿ ༺ ོIT技术༻1 小时前
笔试强训:Day4
c++·算法
老歌老听老掉牙2 小时前
Open CASCADE学习|实现裁剪操作
c++·学习·opencascade·裁剪
姜行运2 小时前
数据结构【二叉搜索树(BST)】
android·数据结构·c++·c#
TPBoreas5 小时前
Jenkins 改完端口号启动不起来了
java·开发语言
TE-茶叶蛋5 小时前
Vuerouter 的底层实现原理
开发语言·javascript·ecmascript
云闲不收6 小时前
设计模式原则
开发语言