![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
微风Jupiter
这个作者很懒,什么都没留下…
展开
-
windows使用cygwin编译redis7.0.5
windows使用cygwin编译redis7.0.5原创 2022-10-11 14:46:00 · 904 阅读 · 0 评论 -
32位linux下使用gettimeofday获取毫秒一直返回负数记录
之前为了测试C++中代码执行消耗的时间,所以写了这么一个函数:long long __getmstime(){ timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1000 + tv.tv_usec / 1000;}之前只是做减法算相差时间,今天突然做了一次输出__getmstime的时间,发现居然是负数,3原创 2014-11-24 20:14:15 · 4554 阅读 · 0 评论 -
C++ string leftTrim rightTrim Trim split
struct TrimFunctor{ bool operator()(const char &ch) { if (ch == ' ' || ch == ' ') { return true; } return false; }};原创 2014-01-06 09:45:18 · 1731 阅读 · 0 评论 -
c++连接mysql5.6出错问题记录
1.描述:链接的时候出错了,错误提示:无法解析的外部符号 _mysql_init@4,该符号在函数 _main 中被引用 原因:我的机器是64bit WIN7系统,VS2012是32bit的,而MySQL是64bit的,32位工程调用64bit的libmysql.lib,因此连接出错啦。 解决:重新安装32bit的MySQL即可。2.描述:编译出错,1>c:\pro原创 2014-12-11 09:28:41 · 1597 阅读 · 0 评论 -
windows平台使用vs2013编译lua-5.2.3
1.解压lua-5.2.3.tar.gz2.进入lua-5.2.3目录,新建批处理文件make.bat,代码如下:md bincd srccl /O2 /W3 /c /DLUA_BUILD_AS_DLL l*.cdel lua.obj luac.objlink /DLL /out:lua52.dll l*.objcl /O2 /W3 /c /DLUA_BUILD_AS_原创 2015-01-01 19:05:07 · 907 阅读 · 0 评论 -
C++堆排序代码
#ifndef HEAP_H#define HEAP_H#include #include templateclass Heap // 依赖<运算{public: Heap():m_data(0), m_size(0), m_max_size(0) { Resize(128); } ~Heap() { if (m_data != 0) free(m_原创 2015-07-04 11:59:13 · 550 阅读 · 1 评论 -
win32 gettimeofday替代方案
来自nginx代码:voidngx_gettimeofday(struct timeval *tp){ uint64_t intervals; FILETIME ft; GetSystemTimeAsFileTime(&ft); /* * A file time is a 64-bit value that represents the n原创 2015-10-06 19:31:00 · 1729 阅读 · 0 评论 -
socket unix domain IPC代码示例
仅供参考:服务端:socket->bind->listen->send/recv->close客户端:socket->bind->connect->send/recv->close#include #include #include #include #include #include #include #include #include #include原创 2015-10-08 20:52:37 · 419 阅读 · 0 评论 -
C++ Muduo网络库基本流程跟踪,学习下
Muduo库基本流程跟踪,学习下 例子中的入口点:int main(){ EventLooploop; TcpServerserver(&loop, listenAddr, "name"); server.start(); loop.loop();} 看TcpServer构造函数:Tcp原创 2015-09-24 15:44:25 · 781 阅读 · 0 评论 -
shp文件头
shp ptr+20:widthptr+24: heightptr+28: xoffsetptr+32: yoffset原创 2016-04-18 10:52:38 · 511 阅读 · 0 评论 -
vs2015中用到的几个插件
1.visual assistx: C++开发必备2.code alignment: 代码对齐工具,可以对齐等号等,让代码更美观3.ForceUTF8: 文件强制保存为utf-8无bom格式4.Indent Guides: 缩进显示竖线5.VsVIM: vim模拟器原创 2016-09-12 16:04:25 · 3822 阅读 · 0 评论 -
win10解决设置默认打开方式不生效问题(双击每次都要选择默认打开程序)
How to change the default programs in Windows 10.系统:windows 10 1803 专业版 (windows 10 professional)现象:1.例如有文件 a.shp文件,需要以后双击默认使用notepad++打开。但是每次双击,都要弹出选择框选择打开方式里面的Notepad++。不能直接打开,很烦很烦有木有。类似这样:...原创 2018-10-27 21:53:13 · 80013 阅读 · 42 评论 -
第一节:grpc1.18.0 c++ windows visual studio 2017(vs2017)版本编译(入门)
0. grpc的github地址,里面也有教程:https://github.com/grpc/grpc.git1. windows使用visual studio 2017编译需要以下几个环境:a.安装git: https://git-scm.com/b.安装golang: https://golang.org/dl/ c.安装cmake: https://cmake.or...原创 2019-01-23 23:05:24 · 4472 阅读 · 2 评论 -
第二节:grpc1.18.0 c++ windows visual studio 2017(vs2017)版本Helloworld示例与解析
上一节入门:https://blog.csdn.net/shan165310175/article/details/86618932 1.使用vs2017新建立一个空的c++ console project,这里我使用debug模式编译.2.拷贝文件:examples/protos/helloworld.proto文件到工程目录,examples\cpp\hellowo...原创 2019-01-23 23:19:12 · 3351 阅读 · 7 评论 -
第一节:protobuf-3.6.1 visual studio 2017(vs2017)编译(入门)
1. 下载protobuf-3.6.1源码:https://github.com/protocolbuffers/protobuf/releases2.下载cmake windows工具(并将bin目录加入到path):https://cmake.org/download/3. 打开cmd工具进入protobuf-3.6.1目录:mkdir installcd cmakemkdi...原创 2019-01-24 12:30:32 · 3167 阅读 · 4 评论 -
第二节:protobuf-3.6.1 visual studio 2017(vs2017) 简单使用
上一节: windows下vs2017编译protobuf 3.6.1: https://blog.csdn.net/shan165310175/article/details/866241191. 新建立console空工程。(这里使用debug编译方式示例)2. 拷贝protoc.exe到工程目录3.工程目录新建立helloworld.proto文件,内容:syntax=...原创 2019-01-24 14:04:43 · 2320 阅读 · 4 评论 -
protobuf编译错误:error C4146: unary minus operator applied to unsigned type, result still unsigned
error C4146: unary minus operator applied to unsigned type, result still unsignederror C4146: 一元负运算符应用于无符号类型,结果仍为无符号类型 设置sdl关闭即可:...原创 2019-01-24 14:14:17 · 4420 阅读 · 0 评论 -
libevent2.1.8-stable中退出异常中断
1.在每个线程构造函数那边,都要添加如下代码:#ifdef WIN32 evthread_use_windows_threads();#else evthread_use_pthreads();#endif否则在loop时候停止会异常中断:event_base_loop(_base, EVLOOP_NO_EXIT_ON_EMPTY);使用如下代码使loop停止:...原创 2019-01-25 16:39:40 · 474 阅读 · 1 评论 -
c++类函数指针,记录一下
#define def(id,contents) \ void foo##id() { cout << "foo: " #contents << endl; }class Test{public: def(1,1); def(2,2); def(3,3);};typedef void (Test::*ClassFunc)();static const ClassFu原创 2014-10-19 15:25:47 · 498 阅读 · 0 评论 -
C++浮点数比较
float x = 0.02f;(x * 100) == 2; // false正确的比较方式:std::abs(x * 100 - 2) <= 1e-6原因是float误差精度是1e-6简单的问题记录一下:P原创 2014-10-19 16:52:40 · 576 阅读 · 0 评论 -
istream_iterator用法及其常见错误
STL定义了供输入及输出的iostream iterator类,称为 istream_iterator和ostream_iterator,分别支持单一型别的元素的读取和写入。 使用方法: 1.包含头文件: #include using namespace std; 2.像使用其他iterator一样使用istream_iterator和 ostream_it转载 2014-01-22 15:16:14 · 2183 阅读 · 0 评论 -
Effective STL个人小笔记
1.不要这么写:class Widget {...};vector vw;Widget bestWidget;... // 给bestWidget一个值vector::iterator i = // 寻找和bestWidget相等的Widgetfind(vw.begin(), vw.end(), bestWidget);要这么写:class Widget { .原创 2014-01-23 17:51:40 · 676 阅读 · 0 评论 -
【转】网游服务端开发入门知识
最近一直想了解一下网络游戏,尤其是MMRPG 的工作原理,上网找到了这篇文章,学习了,在此画个标记。谈这个话题之前,首先要让大家知道,什么是服务器。在网络游戏中,服务器所扮演的角色是同步,广播和服务器主动的一些行为,比如说天气,NPC AI之类的,之所以现在的很多网络游戏服务器都需要负担一些游戏逻辑上的运算是因为为了防止客户端的作弊行为。了解到这一点,那么本系列的文章将分为两部分来谈谈网络转载 2014-02-08 12:39:28 · 834 阅读 · 0 评论 -
C++11 std::ref
void func(int& val){ val = 10;}int main(){ int val = 0; std::bind(func, val)(); std::cout std::bind(func, std::ref(val))(); std::cout }输出:010原因嘛,std:转载 2014-04-16 10:58:52 · 2682 阅读 · 0 评论 -
非阻塞connect errno为EINPROGRESS,如何判断已经连接上了?
via:http://stackoverflow.com/questions/8145624/getpeername-can-not-recognize-connection-established转载 2014-04-17 15:36:16 · 3845 阅读 · 0 评论 -
C++虚析构函数
class A{public: A() { cout << "A ctor." << endl; } virtual ~A() { cout << "A dtor." << endl; }};class B: public A{public: B() { cout << "B ctor." << endl; } ~B() { cout << "B原创 2014-05-18 16:33:50 · 512 阅读 · 0 评论 -
C语言函数sscanf()的用法
via: http://www.cnblogs.com/lyq105/archive/2009/11/28/1612677.html转载 2014-05-23 16:37:57 · 508 阅读 · 0 评论 -
epoll各个触发条件
http://www.cppblog.com/yangsf5/archive/2009/03/12/76353.html转载 2014-07-31 12:46:08 · 1116 阅读 · 0 评论 -
C++容器vector和map的正确删除方法
-原创 2014-08-05 20:45:45 · 1463 阅读 · 0 评论 -
C++ 赋值构造函数注意点
假如有继承operator=首先调用基类的赋值构造函数base::operator=原创 2014-08-28 14:37:52 · 533 阅读 · 0 评论 -
linux c++获取堆栈信息
以下来自muduo的代码:#ifndef MUDUO_BASE_EXCEPTION_H#define MUDUO_BASE_EXCEPTION_H#include #include namespace muduo{class Exception : public std::exception{ public: explicit Exception(const char转载 2014-11-18 10:07:18 · 2039 阅读 · 0 评论 -
指定C++中map的比较函数
简单示例struct Comp{ bool operator()(const int &l, const int &r) { return l == r; }};int main(){ map m; return 0;}原创 2014-01-22 14:27:20 · 1024 阅读 · 0 评论