C、C++混合编译时,C头文件不加 extern "C",函数按照C++编译会改变函数名称,导致link时报undefined reference to `xxx` 的 错误。加 extern "C" 解决,但是直接加的话
-
2021-08-25 14:50:49
-
【解决】double free or corruption (!prev)
*** glibc detected *** cupd: double free or corruption (!prev): 0x093b1208 ***可能原因:1、多次释放同一内存区,需要检查代码,是否出现了对同一内存区释放两
-
【解决】munmap_chunk(): invalid pointer
原因:new malloc出来的指针被覆盖掉了,然后delete free就会报这个错误。例如:char* word = (char*)malloc(10);word = "abc"; 应使用 strcpy(word, "abc");free(word)
-
namespace “std” has no member “clamp”
error: ‘clamp’ is not a member of ‘std’namespace std has no member clampC++17特性,加编译选项 -std=c++17
2021-07-06 16:49:48 -
‘std::tr1’ does not name a template type
解决方法:添加头文件 if !defined(_MSC_VER) include <tr1 memory> endifC++ Technical Report 1 (TR1)是ISO IEC TR 19768, C++ Library Extensions(函式库扩充)的
-
protobuf 是结构化数据的系列化 反序列化解决方案,类似XML JSON,但他的运行效率及压缩率均较后者高一个数量级,且完全的跨平台。使用步骤如下:1、定义一个 proto数据结构文件
2021-07-04 20:07:31 -
编译错误 error: ‘typeof’ cannot be used as a function
编译一些开源的C项目,发现typeof关键字不能被识别,报错:error: ‘typeof’ cannot be used as a function。解决方法:修改C编译选项 -std=gnu99,使用GNU99
-
编译错误 error: ISO C++ forbids declaration of ‘xxx’ with no type [-fpermissive]
比较可能的情况1:函数没有写返回类型,加上返回类型后编译成功。 ifndef ttTree_h define ttTree_hclass ttTree {public: ttTree(void); int ttTreeInsert(int value
2021-06-30 21:18:38 -
gcc编译警告:misleading-indentation
misleading-indentation(不正确的缩进),一般都是Tab及空格的缩进问题导致。实例1:Tab、空格混用将:[空格] if(err)[空格] fprintf(stderr, "op faile
-
C++ std::cout输出2位小数的代码: include <stdio h> include <iostream> include <iomanip> std::setprecision函数需要引入该头文件int main(){ double dval
2021-06-11 13:24:50 -
浅析Linux段错误:SEGV_MAPERR、SEGV_ACCERR
有两种常见的段错误,SIGSEGV 是段错误终止信号,通常是由无效内存访问导致的错误:访问了具有错误权限的页面。例如,它是只读的,但您的代码试图写入它。这将报告为SEGV_ACCERR
2021-06-07 13:25:39 -
c++11 std::call_once只调用一次函数,类似单例模式
std::call_once 保证函数或者一些代码段在并发或者多线程的情况下,始终只会被执行一次,Demo如下: include <iostream> include <thread>static std::once_flag g_once_flag
-
VS编译dll时报编译错误:fatal error LNK1561: entry point must be defined
VS编译dll时报编译错误:fatal error LNK1561: entry point must be defined1、可能是连接命令中的 subsystem不正确,在Project Properties->Linker->System中设置,改为
-
【解决】标准库std::min/std::max 与 Windows.h中的宏 min/max 冲突问题
在包含了Windows h的 C++ 源代码中使用std::min std::max会出现错误。int main(){ int x = std::max(0, 1); int y = std::min(-1, 0);}error C2589: &
-
分享一段LinuxC C++程序只能启动一份实例的实现代码,原理是通过文件锁互斥实现,最重要的是考虑了不同用户运行同一程序互斥的场景,已经过充分的测试,可直接用于实际项目开发。
-
google mock分享(全网最全最好的gmock文档,没有之一)
ContentMatcher(匹配器)基数(Cardinalities)行为(Actions)序列(Sequences)Google Mock 入门概述Google Mock使用Mock实践Google Mock Cookbook什么是Mock?Google Moc
-
1、使用top命令查看内存占用情况,物理内存占用过高时,也重点看一下Swap交换内存占用情况,如果交换内存也开始被使用了,那一定是程序的内存泄漏导致的,Linux使用valgrind工具跟
-
fopen 引起的 malloc(): memory corruption的原因分析
其实不一定是fopen引起的,但引起这个异常的真正元凶通常会在fopen附近,而且直到执行fopen时,调用了内部的malloc,才会抛出这个异常, 这个异常通常是由于数组空间的开辟有问题
-
项目地址:https: github com tsingfun wandbox原项目是日文版的,这里是一个分支版本,添加了一些中文注解,后续可能会部分翻译中中文。官网地址:https: wandbox org ,可以在