![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
felixking
这个作者很懒,什么都没留下…
展开
-
定位内存写入溢出的方法
问题描述C/C++ 使用 alloc 或 new 来分配内存, 但是写入时越界了, 这个问题麻烦的地方在于, 通常情况下(包括debug版本), 内存写入越界的时刻 并不会导致程序crash, 而通常是在 去free这片内存(或其他底层操作)时, 发现 0xfdfdfdfd 栅栏被破坏了才会出现crash, 暴露问题那么, 问题的关键就在于 如何能定位到 最早是哪里发生的写入溢出解决方法当 单纯的作code review 或 code diff 无法解决时, 可以尝试借助 启用页堆,如下是我的理解原创 2022-02-17 20:28:38 · 355 阅读 · 0 评论 -
CMake
可以将一些配置信息,写入CMakeFiles.txt,cmake时生成一个config.h, 然后由源码引用编写 config.h.in#define MAJOR_VERSION @MAJOR_VERSION@#define MINOR_VERSION @MINOR_VERSION@编写CMakeLists.txt# 设置变量set(MAJOR_VERSION 1)set(...原创 2019-10-14 10:48:45 · 332 阅读 · 0 评论 -
OpenGL basic code on Linux in GLX
#include <cstdlib>#include <X11/Xlib.h>#include <GL/glx.h>#include <GL/gl.h>#include <cassert>int main() { // connect to X Server auto displayName = getenv("DISPL...原创 2019-08-23 16:35:05 · 398 阅读 · 0 评论 -
Linux so 文件
Linux与Windows都支持动态链接库,Windows下是dll文件,Linux下是so文件,如果程序执行时没有找到需要的动态链接库,Windows下会出现提示框,Linux下会提示:error while loading shared libraries: xxx.so: cannot open shared object file: No such file or directory...原创 2019-08-21 22:56:11 · 878 阅读 · 0 评论 -
glew first init in GLX
#include <cstdlib>#include <X11/Xlib.h>#include <X11/XKBlib.h>#define GLEW_STATIC#include <GL/glew.h>#include <GL/glx.h>// #include <GL/gl.h>#include <G...原创 2019-08-26 23:15:50 · 161 阅读 · 0 评论 -
[code] xlib event loop for render
#include #include <X11/Xlib.h>#include <X11/XKBlib.h>#include <pthread.h>#include <X11/keysym.h>#include <unistd.h>const int fps = 30;void render(long int monoSpan...原创 2019-08-27 17:00:19 · 178 阅读 · 0 评论 -
C++遗漏知识: 重载函数的值与类型
用C++很久了, 但还是有遗漏的知识点, 观察如下代码:void func(){}void func(int){}auto funcHandle = &func这段代码无法编译通过,提示编译器不能推断出&func的类型, 原因就是func函数有重载, 不论是void func(){}还是void func(int){}获取函数地址时都是用的表达式&fu...原创 2019-09-10 12:39:01 · 296 阅读 · 0 评论 -
demo code - Multi-thread render in GLX
只创建了一个子线程,专门用于渲染子线程中打开了另一个 Display, 并在此Display下创建了 opengl context 和 多个Window子线程有自己的消息循环,因为Window产生的消息貌似只能由创建Window的Display来XNextEvent,主线程中的Display抓不到这些事件主线程中也open了一个Display,并创建了一个gl context,当做资源sh...原创 2019-09-29 15:57:37 · 300 阅读 · 0 评论 -
[code] OpenGL multi thread
// 说明:demo for 主线程创建/删除资源,渲染线程使用资源// 两者貌似主代码层面上可以并行,因为将 MakeCurrent 中的锁注释掉也能正常运行#include <cassert>#include <string>#include <list>#include <vector>// opengl#include &l...原创 2019-10-07 11:18:27 · 431 阅读 · 0 评论