C/C++
大大的道道的
这个作者很懒,什么都没留下…
展开
-
FFMPEG 中的pixfmt 描述符
typedef struct AVComponentDescriptor { /** * Which of the 4 planes contains the component. */ int plane; /** * Number of elements between 2 horizontally consecutive pixels. * Elements are bits for bitstream formats, bytes..原创 2021-01-08 17:25:57 · 745 阅读 · 0 评论 -
Some
1. 冒泡排序void swap( int &x, int &y ){ int c; c=x; x=y; y=c;} int a[10] = { 9,0,3,4,3,5,6,7,8 }; for( int i =0;i!=10;++i ) { for( int j = i+1;j!=10;++j ) { if( a[i]>a[j] ) { swa原创 2017-01-16 10:22:57 · 404 阅读 · 0 评论 -
利用Cmake 将最新版本OBS编译成windows版本。
OBS build pathE:\CSource\directx\workplace\obs-studio-master\buildOBS pathE:\CSource\directx\workplace\obs-studio-master进入plugins\win-dshow执行git clone https://github.com/jp9000/libdsho原创 2016-11-07 18:32:26 · 5081 阅读 · 1 评论 -
Visual Stdio C++ 编译常见问题
new 数组时判断是数组下标的值,如果为负值,会造成crash原创 2015-12-11 10:34:22 · 1264 阅读 · 0 评论 -
C/C++ 常见函数头文件
stdlib:malloc原创 2017-01-04 18:08:03 · 1141 阅读 · 0 评论 -
fork 代码进阶
运行结果是: i son/pa ppid pid fpid 0 parent 2043 3224 3225 0 child 3224 3225 0 1 parent 2043 3224 3226 1 parent 3224 3225 3227 1 child 1 3227 0 1 child 1转载 2017-01-03 16:21:30 · 352 阅读 · 0 评论 -
gcc/g++ 以及makefile
fpic:产生位置无关码解释一下,位置无关码就是可以在进程的任意内存位置执行的目标码,动态链接库必须使用原创 2016-10-08 17:11:45 · 789 阅读 · 0 评论 -
opencv 一些函数的耗时计算
smooth gaussian : 5smooth median : 5cvtColor CV_BGR2Lab : 3accumulateWeighted : 11convertTo CV_8U: 7absdiff: 2threshold: 0dilate 20: 8fill_hole : 1bitwise_xor : 0shape : 0copyT原创 2017-02-22 18:30:26 · 2719 阅读 · 0 评论 -
Const指针 、 指向const的指针 、引用、指针
指向const的指针: 不允许通过指针来改变其指向的const值const double *cptr*cptr = 42; // error! 指针代表的值无法修改const double pi =3.14double *ptr = &pi //error ! 无法将指向const的指针赋值给非非const指针;const double *cptr = &pi //ok原创 2016-09-27 10:04:49 · 279 阅读 · 0 评论 -
段错误原因收集
1. 结构体中有Mat 类型,但是结构体没有写拷贝构造函数,这样拷贝结构体的时候就会出现错误。。2.原创 2017-04-28 13:06:10 · 321 阅读 · 0 评论 -
GDB调试命令
1. 添加断点 某行添加断点 b 2某函数添加断点 b functionName2. 单步调试 s3 . 运行 r4. 查看变量值查看局部变量 info locals打印数组值 p a原创 2016-10-09 09:47:26 · 359 阅读 · 0 评论 -
在Windows中 , 如何用leakdiag “自动”检测内存泄露 (自动记录日志)
打开leakdiag的安装目录,把原来的东西删掉,改为下面内容。(“ ; ”符号的含义是注释,相当于C语言里的“ // ”)[DLPlayer.exe];AutoStart entriesEnableAutoStart=1AutoStartDelay=0AutoStartAllocator=2;AutoDump entriesEnableAutoDump=1原创 2016-03-04 11:34:42 · 2309 阅读 · 0 评论 -
gcc/g++ 编译常见问题
1. error: ‘for’ loop initial declarations are only allowed in C99 mode这是因为gcc基于c89标准,换成C99标准就可以在for循环内定义i变量了:gcc src.c -std=c99 -o src原创 2016-10-14 09:35:03 · 1263 阅读 · 0 评论 -
Makefile中 -I -L -l区别
我们用gcc编译程序时,可能会用到“-I”(大写i),“-L”(大写l),“-l”(小写l)等参数,下面做个记录:例:gcc -o hello hello.c -I /home/hello/include -L /home/hello/lib -lworld上面这句表示在编译hello.c时:-I /home/hello/include表示将/home/hello/incl原创 2016-09-07 11:52:33 · 36136 阅读 · 4 评论 -
【设计模式】 工厂模式实例 C++ , 利用工厂模式写一个计算器
#include <iostream>class Calculator{public: virtual double cal()=0; Calculator(){} void setValue(double _a, double _b) { a=_a; b=_b; }public: double a; double b;};class...原创 2018-08-01 14:14:00 · 484 阅读 · 0 评论 -
opencv 单目标模板匹配(只适用于模板与目标尺度相同)
#include #include "opencv/cv.h" #include "opencv/cxcore.h" #include "opencv/highgui.h" using namespace std; #pragma comment ( lib,"opencv_highgui244.lib" )#pragma comment ( lib,"opencv_c原创 2016-11-29 14:42:03 · 696 阅读 · 0 评论 -
关于内存越界
1. 原理分析经常有些新C++程序员问:C++的类的成员个数是不是有限制,为什么我加一个变量后程序就死了?或者说:是不是成员变量的顺序很重要,为什么我两个成员变量顺序换一换程序就不行了?凡此种种之怪现象,往往都是内存访问越界所致。何谓内存访问越界,简单的说,你向系统申请了一块内存,在使用这块内存的时候,超出了你申请的范围。例如,你明明申请的是100字节的空间,但是你由于某种原因写入了1转载 2016-01-24 17:23:43 · 521 阅读 · 0 评论 -
【转】[STL]vector和deque的内存释放(clear)
vector的clear成员函数可以清除vector中的元素,使其大小减至0。但它却不能减小vector占用的内存。[cpp] view plain copyint main() { vectorint> v(1U cout"step into stage one..." sleep(30);转载 2016-01-28 14:41:31 · 2209 阅读 · 0 评论 -
Vector , list 和 deque的区别
vector 表示一段连续的内存区域,每个元素被顺序存储在这段内存中,对vector 的随机访问效率很高,但对非末尾元素的插入和删除则效率非常低。 deque 也表示一段连续的内存区域,但与vector不同的是它支持高效地在其首部插入和删除元素,它通过两级数组结构来实现,一级表示实际的容器,第二级指向容器的首和尾 list 表示非连续的内存区域并通过一对指向首原创 2016-04-03 20:05:33 · 231 阅读 · 0 评论 -
String Class
#include #include #include using namespace std;template void print(T1& t1, T2& t2 ){ t1<<t2;}原创 2016-04-04 00:21:07 · 261 阅读 · 0 评论 -
最简单的一个win32程序
#include HINSTANCE g_hInst = NULL;//2 窗口处理函数LRESULT CALLBACK WndProc( HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam ){ //判断消息ID switch( nMsg ) { case WM_DESTROY:原创 2016-03-11 15:41:44 · 216 阅读 · 0 评论 -
windows 无法找到unistd.h 的解决方法
//#include #ifndef _UNISTD_H#define _UNISTD_H #include #include原创 2016-05-15 17:02:49 · 7143 阅读 · 2 评论 -
【C++专题】static_cast, dynamic_cast, const_cast探讨
【C++专题】static_cast, dynamic_cast, const_cast探讨 首先回顾一下C++类型转换:C++类型转换分为:隐式类型转换和显式类型转换第1部分. 隐式类型转换又称为“标准转换”,包括以下几种情况:1) 算术转换(Arithmetic conversion) : 在混合类型的算术表达式中, 最宽的数据类型成为目转载 2016-05-21 22:32:56 · 260 阅读 · 0 评论 -
C++ error
1. error LNK2005: "void __cdecl ······已经在 ChildView.obj 中定义头文件重复包含了,加入#pragma once ,清理解决方案,然后重新编译。原创 2016-06-28 00:30:14 · 232 阅读 · 0 评论 -
一个SDL2.0程序的分析
。。原创 2016-09-13 10:57:57 · 968 阅读 · 0 评论 -
C++ 构造函数后面的冒号的作用
其实冒号后的内容是初始化成员列表,一般有三种情况: 1、对含有对象成员的对象进行初始化,例如, 类line有两个私有对象成员startpoint、endpoint,line的构造函数写成: line(int sx,int sy,int ex,int ey):startpoint(sx,sy),endpoint(ex,ey){……} 初始化时按照类定义中对象成原创 2016-09-18 09:31:41 · 7135 阅读 · 0 评论 -
不可轻视复制构造函数
如果不主动编写拷贝构造函数和赋值函数,编译器将以“位拷贝”的方式自动生成缺省的函数。倘若类中含有指针变量,那么这两个缺省的函数就隐含了错误。以类 String 的两个对象 a,b 为例,假设 a.m_data 的内容为“ hello”,b.m_data 的内容为“ world”。 现将 a 赋给 b,缺省赋值函数的“位拷贝”意味着执行 b.m_data = a.m_data。转载 2016-09-18 17:58:14 · 226 阅读 · 0 评论 -
编译程序遇到问题 relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;
编译程序遇到问题 relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;发现编译的程序引用的一个库(.a文件)是直接用./configure 编译的, 64位机器不能直接./configure 进行配置,需要采用如下方式CFLAGS="-O3 -fPIC"原创 2016-09-23 16:53:32 · 5722 阅读 · 0 评论 -
ubuntu下安装openssl库
apt-get install libssl-dev原创 2016-10-10 15:04:05 · 1146 阅读 · 0 评论 -
常见数据类型的字节数
常见数据类型的字节数#include int main(){ int a = sizeof( unsigned char ); //1 int b = sizeof( char ); //1 int c = sizeof( unsigned int ); //4 int d = sizeof( int ); //4 int e = sizeof( short原创 2016-10-09 10:12:55 · 614 阅读 · 0 评论 -
C++ 常见格式转换
1. const char * 转 char* 指向const的指针不能被赋给指向非const的指针,所以应该用strcpy,也就是另开一块内存,把字符一个个复制过去,示例如下: const char *expr = "goodidea"; char *buf = new char[strlen(expr)+1]; strcpy(buf, expr);原创 2016-10-12 09:48:07 · 731 阅读 · 0 评论 -
linux core文件的打开和分析
1. core文件打开方式: ulimit -c unlimitedecho "1" > /proc/sys/kernel/core_uses_pid看下服务器上是否安装了 gdb,没有的话要装一下以调试模式打开程序 ./sip_gw -t2 -n 1之后程序会crashed, 程序目录会生成一个core文件,2. core 文件分析查看core原创 2016-10-25 10:11:11 · 690 阅读 · 0 评论 -
MFC如何显示位图
1. 资源文件中加载 bmp2.1. 静态加载图片 在属性下设置为如下即可2.2 动态加载图片其中要在控件中添加CStatic变量,并且属性设置为如下并且在按钮控件中加入 如下代码void CdisplayPictureByMFCDlg::OnBnClickedOk(){// TODO: 在此添加控件通知处理程序代码原创 2015-12-17 09:51:05 · 1406 阅读 · 0 评论