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>

相关推荐
博笙困了19 小时前
AcWing学习——双指针算法
c++·算法
感哥20 小时前
C++ 指针和引用
c++
感哥1 天前
C++ 多态
c++
沐怡旸2 天前
【底层机制】std::string 解决的痛点?是什么?怎么实现的?怎么正确用?
c++·面试
River4162 天前
Javer 学 c++(十三):引用篇
c++·后端
感哥2 天前
C++ std::set
c++
侃侃_天下2 天前
最终的信号类
开发语言·c++·算法
博笙困了2 天前
AcWing学习——差分
c++·算法
echoarts2 天前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
Aomnitrix2 天前
知识管理新范式——cpolar+Wiki.js打造企业级分布式知识库
开发语言·javascript·分布式