一、gprof测试用例#include <iostream>
#include <vector>
#include <chrono>
#include <thread>
// 递归阶乘函数
unsigne...
阅读全文...
基于protobuf开发的rpc框架
RPC(Remote Procedure Call Protocol)远程过程调用协议,过程示意图一、提供方配置1.1、生成服务对象要提供RPC服务,需要在proto中添加service信息,protoc会为每个service生成对应的C++类,包含虚函...
阅读全文...
阅读全文...
epoll简单使用示例
#include <cerrno>
#include <cstdlib>
#include <sys/epoll.h>
#include <unistd.h>
#include <sys/socket...
阅读全文...
阅读全文...
C++ 报错:'xxx' has not been declared
'xxx' has not been declared原因是头文件互相包含[build] D:/a-mycode/C++/DDZ-NET/client-ddz/thread/include/Communication.h:87:5: error: 'Da...
阅读全文...
阅读全文...
C++ 报错:fstream打开相对路径文件发生错误
问题:C++使用fstream打开相对路径文件发生错误,只能使用绝对路径,下面是项目结构如上图,原以为相对路径是相对于二进制文件(server-ddz.exe)的路径,所以使用相对路径../config/config.json,但是经过测试,还是相对路径...
阅读全文...
阅读全文...
C++ 报错:‘xxx’ does not name a type
‘xxx’ does not name a type原因是由于头文件互相包含(循环依赖)导致的/mnt/d/a-mycode/C++/DDZ-NET/server-ddz/tcp/include/TcpConnection.h:31:5: error: ...
阅读全文...
阅读全文...
如何在CMake中正确的添加库文件:MSVC与MinGW混用陷阱
记一次在windows+cmake+MinGW环境下使用openssl添加库文件错误的经历一、库文件介绍OpenSSL下载路径:https://slproweb.com/products/Win32OpenSSL.html安装后的库文件是这样的bin目录...
阅读全文...
阅读全文...
C++ 报错:cannot found -lxxx
cannot found -lxxx动态库找不到动态库文件,排查方向在当前CMakeLists.txt文件下使用link_directories指定动态库路径set(PROTOBUF_PATH "D:/protobuf-cpp-3.21.12&...
阅读全文...
阅读全文...
C++ 报错:undefined reference to ‘xxxx’
undefined reference to ‘xxx’函数#情况1,库链接顺序不正确导致,明显特征是报错的函数是我们自己实现的函数,而不是底层函数
[build] D:/a-mycode/C++/DDZ-NET/client-ddz/window/lo...
阅读全文...
阅读全文...
C++封装OpenSSL哈希类
一、 基本用法// 创建MD5哈希对象
CryptographicHash hash(CryptographicHash::HashType::Md5);
// 添加数据
hash.addData("Hello World");
...
阅读全文...
阅读全文...
vscode C++环境搭建
C++插件:快速生成类,快捷键:Alt+XC++ Class Creator代码格式化,快捷键:shift+alt+fClang-Format使用clangd索引clangdCMake Tools快速生成文档Doxygen Documentation G...
阅读全文...
阅读全文...