
linux
weixin_39446424
c/c++方向
展开
-
Linux中源码安装protocbuf 和protobuf-c
首先安装protocbufprotocbuf下载路径:https://github.com/protocolbuffers/protobuf/releases按照下面步骤安装:#解压tar xzf protobuf-all-3.11.4.tar.gz#编译并安装cd protobuf-all-3.11.4./configure --prefix=/usr/local/protobu...原创 2020-03-19 11:21:52 · 508 阅读 · 0 评论 -
共享内存中不能存储---类中有申请空间的类对象
背景有一个需求,作为客户端需要从redis集群中获取数据。出于性能的考虑,再客户端初始化阶段,初始化了一个redis连接,后续在连接redis时,可以直接使用该连接,不用再去重新连接redis了。(这里指的连接其实就是初始化一个类对象,然后根据ip+prot连接redis集群)但是这样的操作有一个问题就是,当有多个客户端连接redis集群时,由于连接数过多,达到redis节点连接数的限制(默认...原创 2019-12-31 10:16:12 · 340 阅读 · 0 评论 -
linux中通过信号实现定时操作
#include <stdio.h>#include <string.h>#include <unistd.h>#include <signal.h>void test(){ printf("this is a test\n");}void func(int a){ test(); alarm(5);//5s后...原创 2019-12-19 15:49:56 · 319 阅读 · 0 评论 -
strptime和strftime互转时间
strptime :将格式化的字符串解析存储到struct tm结构中去strftime :将struct tm结构格式化为指定字符串代码示例#include <iostream>#include <time.h>#include <string.h>using namespace std;int main(){ const char *...原创 2019-12-19 11:38:00 · 271 阅读 · 0 评论 -
使用mqopen mq_receive mq_close和sem_open sem_wait sem_post给不同进程发送任务去执行
mqopen mq_receive mq_close和sem_open sem_wait sem_post联合使用#include <stdio.h>#include <semaphore.h>#include <mqueue.h>#include <unistd.h>#include <string.h>#include "...原创 2019-11-26 11:23:00 · 313 阅读 · 0 评论 -
分级别打印日志
#文件log.h该文件中定义了打印日志的接口。#ifndef _LOG_H_#define _LOG_H_#define INFO_OUTPUT 3#define WARNING_OUTPUT 2#define DEBUG_OUTPUT 1#define ERROR_OUTPUT 0#define LOG_INFO(args,...)\do{\...原创 2019-05-23 14:29:01 · 619 阅读 · 0 评论 -
源码安装git-2.20.1版本
参考这个链接https://www.cnblogs.com/gsliuruigang/p/7899803.html这里有可能找不到configure这个文件,这里我们需要再解压的路径下执行make configure这个命令,执行后,再继续执行./configure --prefix=/usr/local/git后面就按照链接里面说的来即可!...转载 2019-07-24 09:19:35 · 154 阅读 · 0 评论 -
boost::function参数为空时,可以接收boost::bind有参数的函数
代码示例:#include<boost/function.hpp>#include<boost/bind.hpp>#include<iostream>typedef boost::function<int(int)> Func;int test(int num,char ch){ std::cout<<num<&...原创 2019-08-06 11:23:56 · 295 阅读 · 0 评论