
C/C++
干煸四季豆123
还好吧
展开
-
fflush与fsync的区别,确保掉电瞬间数据尽量写入磁盘
fwrite 使用fsync,write使用sync()原创 2020-02-10 11:52:42 · 897 阅读 · 1 评论 -
taskset绑定linux下CPU核心调度
taskset -p 0x01 10056表示PID为10056的进程只能在第1个核心上运行taskset -p 0x08 10056表示PID为10056的进程只能在第4个核心上运行taskset -p 0x0c 10056表示PID为10056的进程只能在第3和第4个核心上运行...原创 2020-01-13 16:51:46 · 622 阅读 · 0 评论 -
C++11笔记一
0000;short anotherNum{largeNum }; // error! Amend typesint anotherNum{largeNum}; // OK!float someFloat{largeNum}; // error! An int may be narrowedfloat someFloat{500000}; //OK! 500000 can be accomodated 二,C++11引入了固定宽度的整形,能够以位为单位指定整数的宽度。这些类型为i原创 2019-04-22 18:09:32 · 147 阅读 · 0 评论 -
程序在内存中的分布
转自:https://www.cnblogs.com/share-happy-everyday/p/9371910.html代码段(.text),也称为文本段(Text Segment),存放着程序的机器码和只读数据,可执行指令就是从这里取得。如果可能,系统会安排好相同程序的多个运行实体共享这些实例代码。这个段在内存中一般被标记为只读,任何对该区的写操作都会导致段错误(Segmentati...转载 2019-07-30 14:47:22 · 167 阅读 · 0 评论 -
caffe_windows1.0扩展upsample层
报错缺少upsample层:google.protobuf.text_format.ParseError: 2622:5 : Message type "caffe.LayerParameter" has no field named "upsample_param".扩展方式如下,基于caffe_windows,版本1.0:1、修改D:\caffe-windows\src\caffe\p...原创 2019-09-02 16:27:19 · 1295 阅读 · 3 评论 -
RuyiStudio项目在编译后无法正常执行
安装好Ruyi Studio,踩了两天坑。1、在RuyiStudio中运行Release无任何反应,如下图一2、在RuyiStudio中运行Debug报错,如图二3、在CMD中运行Release报错,如图三解决过程:1、检查项目环境是否为指定目录:在Ruyi Studio中选中项目,右键->Properties->C/C++ Build->Environment:...原创 2019-09-03 11:27:38 · 1495 阅读 · 1 评论 -
通过变长模版参数创建一个模版参数类型都是std::vector<T>的tuple
链接:https://www.zhihu.com/question/38949490/answer/78918985template <typename ...Types>struct store{};template <>struct store<>{ using type = std::tuple<>;};t...转载 2019-07-30 11:36:24 · 332 阅读 · 0 评论 -
关于子线程释放的时机
void test() { ThreadRunner mThread("test"); int mCount = 1; mThread.start([&mCount] { mCount++; printf("thread run...%d\n", mCount); std::chrono::milliseconds sleepDuration(2000); std:...原创 2019-07-30 11:26:37 · 237 阅读 · 0 评论 -
LInux进程间通讯IPC
原创 2019-04-26 17:36:58 · 507 阅读 · 0 评论 -
C++11笔记四
:for_each/find_if/sort/partition/remove_if等,使用方便;#include <iostream>#include <string> using namespace std;template <typename T>int funcAdd(T t1, T t2) { return t1 + t2;}template <typena原创 2019-04-30 16:48:01 · 158 阅读 · 0 评论 -
C++11笔记三
ase {private: int age = 10; std::string tostring; // 必须要全局变量public: MyBase() { cout << "MyBase construct..." << endl; } operator const char*() { tostring = "toString:" + std::to_原创 2019-04-24 19:08:30 · 150 阅读 · 0 评论 -
C++11笔记二
) { num=n; }//普通构造函数private: int num;};class Test2{public: explicit Test2(int n) { num=n; }//explicit(显式)构造函数private: int num;};int main(){ Test1 t1=12;//隐式调用其构造函数,成功 Test2 t2原创 2019-04-23 18:44:36 · 153 阅读 · 0 评论 -
MFC ActiveX开发记录
原创 2019-04-11 17:28:04 · 86 阅读 · 0 评论 -
vs2015下protobuf编译使用
原创 2019-04-23 11:20:47 · 386 阅读 · 0 评论 -
unique_ptr+char*
string>("abcde"); cout << "bbc2:" << bbc2->data() << endl;原创 2019-01-27 12:51:49 · 2188 阅读 · 0 评论 -
c++11格式化打印日志
_point_cast<std::chrono::milliseconds>(std::chrono::system_clock::now()); auto tmp=std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch()); std::time_t timestamp = tmp.count(); return timestam原创 2019-01-11 23:21:48 · 2148 阅读 · 0 评论 -
linux C++守护进程保障启动其它程序
;#include<sys/stat.h>#include<stdio.h>#include<stdlib.h>#include<time.h>#include<fcntl.h>#include<string.h>#include<termios.h>#include <原创 2019-04-26 17:37:55 · 2557 阅读 · 0 评论 -
linux下执行shell
open(sysCommand, "r")) == NULL) { MY_LOGE("---runCommand error...\n"); return -1; } if(result==NULL||readLen==0) { MY_LOGE("---runCommand not need result...\n"); pclose(fp); return 0;原创 2019-04-26 17:49:50 · 172 阅读 · 0 评论 -
AF_UNIX实现linux本地socket通信的笔记
原创 2019-05-15 14:47:41 · 4388 阅读 · 0 评论 -
C++11笔记五
一,右值及右值引用 C++11中所有的值,必属于左值、将亡值、纯右值三者之一,将亡值和纯右值,都属于右值。 1、左值是指表达式结束后依然存在的持久对象; 2、右值是指表达式结束时就不存在的临时对象; 1)将亡值,C++11新增,与右值引用相关的表达式,比如:将要被移动的对象、T&&函数返回值、std::move返回值和转换为T&am...原创 2019-07-31 13:16:56 · 330 阅读 · 0 评论 -
C++11应用:对象池
class ObjectPool{ template <typename... Args> using Constructor = std::function<std::shared_ptr<T>(Args...)>;public: ~ObjectPool() { destructedFlag = true; } // 默认创建多少个对象 template <typ原创 2019-04-29 00:00:42 · 240 阅读 · 0 评论 -
C++11应用:占位模式
原创 2019-04-28 21:40:55 · 197 阅读 · 0 评论 -
C++11应用:访问者模式
原创 2019-04-28 16:46:08 · 189 阅读 · 0 评论 -
C++11应用:规范日志打印
cast<std::chrono::milliseconds>(std::chrono::system_clock::now()); auto tmpNow=std::chrono::duration_cast<std::chrono::milliseconds>(tpNow.time_since_epoch()); uint64_t milli = tmpNow.count(); milli += (uint64_t)8原创 2019-04-28 14:27:06 · 461 阅读 · 0 评论 -
C++11应用:观察者模式(多函数对象回调)
原创 2019-04-28 14:21:57 · 376 阅读 · 0 评论 -
C++11应用:单例模式
=(const Singleton&) {}; static T* mInstance; public: template <typename... Args> // 创建单例 static T* Instance(Args&&... args) { if (mInstance == nullptr) { mInstance = new T(std::forward<A原创 2019-04-28 14:22:09 · 148 阅读 · 0 评论 -
c++11获取当前linux系统时间并格式化毫秒级
system_clock::now()); auto tmp=std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch()); std::time_t timestamp = tmp.count(); return timestamp;}std::tm* gettm(uint64_t timestamp){ uint64_t milli =原创 2019-01-11 12:49:21 · 3260 阅读 · 0 评论