自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(47)
  • 收藏
  • 关注

原创 动态库链接静态库防止符号污染

动态库链接静态库,污染动态库问题

2023-01-09 14:07:21 979

原创 gnutls_handshake() failed: Error in the pull function.

fix git handshake error

2022-12-08 21:08:04 595

原创 多个任务的最短执行时间 std::async

正所谓一个木桶能装多少水, 取决于最短的木板,多个任务执行的最长时间,取决于多个任务中最长的时间。#include <iostream>#include <future>#include <chrono>#include <unistd.h>#include <ctime>int func1() { sleep(10); return 1;}int func2() { sleep(5); return 2;

2022-02-15 22:27:57 634

原创 在头文件中实现单例类,在二进制文件中会有多个实例吗?

答案:不会。为什么会有这个疑问呢?我们在多个cpp 包含同一个头文件后,在每个编译单元(cpp文件)编译的时候都会有一份,既然这样,那我们的一个静态实例对象在每个编译单元会不会都有一份,然后可执行二进制文件中会不会有多份呢?测试一把// static_test.h#pragma once#include <stdio.h>class static_test { public: static static_test * Instance() { s

2021-12-17 20:09:30 415

原创 多叉树格式化打印

效果如下└──0 ├──1 │ ├──11 │ │ ├──111 │ │ └──112 │ └──12 │ └──13 │ └──14 └──2 ├──21 └──3代码如下#include <iostream>#include <vector>#include <memory>class MNode;...

2021-12-04 20:15:22 1308

原创 signal handler 例子

#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <signal.h>#include <iostream>void sig_handler(int i) { std::cout << "sig_handler int" << std::endl; exit(1);}int main() { ...

2021-10-14 14:53:11 425

原创 linux下解压img,提取对应文件

假设img名字为system.img1. 解压 imgsimg2img system.img system.img.old2. 新建路径用于 mount:mkdir test3. mount image:sudo mount -t ext4 -o loop system.img.old test/这时,system.img.old 的内容会 mount 到 test 下,打开 test 查看。4.修改 test 内容后重新打包成新的 im...

2021-10-11 21:10:31 4003

原创 uyvy422 shader 贴图及效果分析

uyvy422在纹理贴图的时候经常出现竖条纹。在v4l的库里找到一个方法,验证下来不会出现竖条纹。转纹理方式: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_frameWidth / 2, m_frameHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);fragment shaderuniform float texture_width;uniform float texture_height

2021-10-03 12:51:28 881

原创 linux消息队列发送结构体

mq_common.hmq_service.cppmq_cleint.cpp

2021-09-29 21:13:30 7918

原创 shared_ptr<void*> 能否释放内存?

#include <iostream>#include <memory>class A { public: int a ; ~A() { std::cout << "~A" << std::endl; } A() { std::cout << "A" << std::endl; }};..

2021-09-28 18:13:32 473

原创 递归和非递归版本的快速排序

#include <iostream>#include <vector>#include <stack>template <typename T> void swap(T * t1, T * t2) { T tmp = *t1; *t1 = *t2; *t2 = tmp;}// 递归版本void quicksort(std::vector<int> & vec, int begin, int ..

2021-09-27 11:59:06 66

原创 传递类成员函数作为回调函数

bind 类实例对象#include <iostream>#include <string>class A { public: int a = 1; void f(int a1, int b1) { std::cout << "a1" << a1 << ", b1" << b1 << std::endl; }};using C

2021-09-24 14:37:34 7936 1

原创 10x10的黑白格,计算相邻黑白格的最大面积

#include <iostream>#include <math.h>#include <tuple>#include <utility>#include <vector>constexpr int len = 10;// black is true, white is false;#define BLACK (true)#define WHITE (false)using COLOR = bool;COLOR pane..

2021-09-16 17:51:25 7663

原创 带有虚函数的class的size如何计算?

先说结论:1. 非虚函数,不占空间,为类共享2. 带虚函数class,只占一个虚函数表的指针的空间。3. 子类和父类共享一个虚函数表指针。测试code:#include <iostream>class A { public: virtual void f1() {}};class B { public: virtual void f2() {} virtual void f3() {}};c

2021-09-10 17:53:00 7943

原创 xmake 中 ifneq/ifeq 逻辑 and

xmake 组织的是gnu make的表达。因此逻辑and参照make中的表达。管用的做法:ifeq ($(condition1),TRUE)ifeq ($(condition2),FALSE)# do somethingendifendif参照https://stackoverflow.com/questions/6451477/makefile-ifeq-logical-and...

2021-09-10 17:33:00 7783

原创 归并排序 mergesort

#include <iostream>#include <vector>#include <stdlib.h>#include <chrono>#include <cmath>#include <algorithm>template <typename T> inline void swap(T * t1, T * t2) { T tmp = *t1; *t1 = *t2; *t2 ..

2021-09-07 20:27:22 10089

原创 子类转成基类指针,使用智能指针包装,会造成内存泄漏吗?

答案是不会。#include <iostream>#include <string>#include <memory>class A { public: A() { std::cout << "A" << std::endl; } ~A() { std::cout << "~A" << std::endl;

2021-09-07 15:22:53 19886

原创 冒泡排序 vs 快速排序 vs 归并排序

#include <iostream>#include <vector>#include <stdlib.h>#include <chrono>template <typename T> inline void swap(T * t1, T * t2) { T tmp = *t1; *t1 = *t2; *t2 = tmp;}template <typename T>void quickso..

2021-09-06 15:02:37 10028

原创 快速排序 quick sort

#include <iostream>#include <vector>template <typename T> inline void swap(T * t1, T * t2) { T tmp = *t1; *t1 = *t2; *t2 = tmp;}template <typename T>void quicksort(std::vector<T> & vec, int sortBegin, ..

2021-09-06 14:21:11 9147

原创 冒泡排序 bubble sort

#include <iostream>#include <array>template <typename T> void swap(T * t1, T * t2) { T tmp = *t1; *t1 = *t2; *t2 = tmp;}template <typename T, std::size_t Dim>void bubblesort(std::array<T, Dim> & arr) {..

2021-09-06 11:34:43 10064

原创 -fno-elide-constructors 构造函数编译器优化

看到网上的一段测试移动构造函数的代码,如下,结果只走了默认构造函数#include <iostream>class A { public: A() { std::cout << "default Constructor" << std::endl; } A(const A&) { std::cout << "copy Constructor

2021-08-23 14:15:33 10647

原创 cmake(add_library) No SOURCES given to target: XXXX

cmake 版本:3.20.0。编译某工程,报错如下:CMake Error at build/core.cmake:147 (add_library): No SOURCES given to target: XXXXbuild/core.cmake第147行代码如下:add_library(${name} SHARED)问题很明确,add_library需要在添加source文件。那么问题来了,其他人都可以编译通过,但是我这儿为什么不行呢。通过实验,我发现在低版..

2021-05-26 16:30:36 37727 9

原创 nerdtree目录结构跟随vim打开的文件自动跳转

在.vimrc中添加如下代码" Check if NERDTree is open or activefunction! IsNERDTreeOpen() return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)endfunction" Call NERDTreeFind iff NERDTree is active, current window contains a modi...

2021-04-01 13:18:31 11213

原创 node   Reason: image not found

dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.67.dylib Referenced from: /usr/local/bin/node Reason: image not found解决办法:brew upgrade npm

2021-03-24 15:56:01 434

原创 TVM 脚本错误: module ‘tvm‘ has no attribute ‘testing‘

import tvm.testing

2021-03-23 18:00:04 10370

原创 文件名按照自定义类型大小排序

#include <iostream>#include <vector>#include <string>#include <algorithm>int main() { std::vector<std::string> a = {"11", "12", "13", "21", "22", "111", "109", "136", "255"}; std::sort(a.begin(), a.end(..

2021-03-12 14:11:46 10253

原创 根据角度,求椭圆边上点的坐标

只考虑焦点在坐标轴,质点在圆心的情况#include <math.h>#include <iostream>#include <utility>inline float degrees_to_radians(float deg) { return deg / 180.0 * M_PI;}inline float radians_to_degrees(float rad) { return rad / M_PI * 180.0;}//

2021-03-12 11:47:01 11767

原创 yuv 转 jpg, jpg 做成 mp4

yuv转jpg用到了 ffmpeg,jpg做成mp4用到了opencv参考代码import osimport cv2from functools import cmp_to_keyimage_folder = "XXXXX"image_output_folder = "XXX"video_name = image_output_folder + "output.avi"timestampefile = image_output_folder + "timestampe.tx.

2021-03-08 13:47:30 10278

原创 共享内存 shared memory 例子

write client/* Filename: shm_write.c */#include<stdio.h>#include<sys/ipc.h>#include<sys/shm.h>#include<sys/types.h>#include<string.h>#include<errno.h>#include<stdlib.h>#include<unistd.h>#includ...

2021-03-04 12:07:37 10305 1

原创 System V 信号量

写了一个demo,用来测试信号量,在终端起两个demo/* t_semget.c Licensed under GNU General Public License v2 or later.*/#include <sys/types.h>#include <sys/ipc.h>#include <sys/sem.h>#include <sys/stat.h>#include <stdio.h>#include &.

2021-03-03 21:35:56 10017 1

原创 zsh 错误:no such file or directory: /usr/local/share/zsh/site-functions/_brew

存模型与atomic

2021-03-03 15:35:08 12431 1

原创 系统调用之epoll

epoll的介绍详细请看 man epoll, 或者https://man7.org/linux/man-pages/man7/epoll.7.html 或者有人翻译过了https://www.jianshu.com/p/ee381d365a29自己写了个例子测试, 建立两个fifo, 然后传入给epoll, 向fifo中写入字符串。#include <fcntl.h>#include <sys/types.h>#include <sys/...

2021-03-02 19:30:25 10240

原创 系统调用之select

what is select?example例子1, 最简单的官方select例子。#include <stdio.h>#include <stdlib.h>#include <sys/select.h>int main(void){ fd_set rfds; struct timeval tv; int retval; /* Watch stdin (fd 0) to see when it has inp.

2021-03-02 11:01:08 10392

原创 系统调用之poll

What is poll?How to use?在https://man7.org/linux/man-pages/man2/poll.2.html中给出了一个简单的例子,可以实现poll多个fds,一旦其中一个fd ready,poll就会返回。/* poll_input.c Licensed under GNU General Public License v2 or later. */#include <poll.h>#include <fcnt.

2021-03-01 19:00:31 10896

原创 信号集 SIGINT, SIGTERM, SIGKILL

SIGINT:程序终止信号。当用户按下CRTL+C时通知前台进程组终止进程。SIGTERM:程序结束信号,可以使用 kill <pid> 触发SIGKILL:用来立即结束程序的运行。可以使用kill -9 <pid> 触发SIGTERM和SIGKILL的区别:SIGTERM信号是可以被捕获的,因此可以尝试block,或者忽视,但是SIGKILL不能。下面写了一个简单的例子来佐证这个事情 sig_test.cpp:#include <stdlib...

2021-03-01 17:43:48 11967

原创 pthread链接问题导致弱符号例子失败

在《程序员的自我修养》一书中介绍强符号和弱符号:里面这样写道:规则1:不允许强符号被多次定义(即不同的目标文件中不能有同名的 强符号);如果有多个强符号定义,则链接器报符号重复定义错误。规则2:如果一个符号在某个目标文件中是强符号,在其他文件中都是 弱符号,那么选择强符号。规则3:如果一个符号在所有目标文件中都是弱符号,那么选择其中占 用空间最大的一个。比如目标文件A定义全局变量global为int型,占4个 字节;目标文件B定义global为double型,占8个字节,那么目标文件A和

2021-02-19 21:16:06 10260 10

原创 ubuntu下 opencv with cuda 编译

1. 下载opencvhttps://github.com/opencv/opencv2. 下载opencv_contribhttps://github.com/opencv/opencv_contrib3. 编译在opencv目录下建立build文件夹,cd build,执行cmake需要打开cuda选项,配置cuda路径cmake -DCMAKE_INSTALL_PREFIX=/home/super/workspace/thirdparty/opencv -DCMAKE_BUIL...

2021-02-06 22:23:25 10748

原创 Vim 8.1 打开javascript 文件卡死

近期发现一个问题 VIM打开js后,拖动比较卡,打开C/C++比较正常。看到网上有人说关闭高亮可以解决此问题, 尝试了一下,确实可以。关闭方法" syntax on // 注释掉或者 syntax off但是没有高亮是不能接受的。最后在Stackoverflow上找到了正解。方法:set re=0 // 或者 set regexpengine=0解释:vim有两套正则表达式引擎,他们有不同对适用场景。最好对办法是设置为0,让vim自己去选择。详细可以参照.

2021-02-05 18:36:10 10343

原创 ubuntu 台式机使用无线网络体验

1. 网购了一款USB无线网卡TL-WN726N2; 编译驱动https://github.com/brektrou/rtl8821CU3. 链接wifi

2020-06-28 13:00:29 10480

原创 Cario 缩放与偏移的例子

最近遇到一个问题,使用需要将一个surface的内容,进行缩放和偏移,贴到另外一个surface上, 发现自己对Transforms have three major uses. First they allow you to set up a coordinate system that's easy to think in and work in, yet have the output be of any size. Second they allow you to make helper fun

2020-06-13 15:18:52 559

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除