- 博客(101)
- 资源 (6)
- 收藏
- 关注
原创 MS VC 2022开发Linux应用记录之02篇-开发调试Linux QT应用
首先 vim ~/.bashrc 然后在里面添加 export QT_QPA_PLATFORM='offscreen' 即时生效 source ~/.bashrc 这样就可以额 每次修改.bashrc后,使用source ~/.bashrc(或者 . ~/.bashrc) 就可以立刻加载修改后的设置,使之生效。vim /etc/profile , 添加 export DISPLAY=:0.0 ,wq,保存退出 ,再 source /etc/profile 生效。
2023-07-23 01:06:44 235
原创 MS VC 2022开发Linux应用记录之01篇
13. 在代码中设置断点,按F5进行调试。单步运行,可以从Linux终端中看到一步步的输出。14.也可以在虚拟机的~/.vs目录下找到上述C++项目,并可运行生产的目标程序。12. 生成程序,可以在linux终端中运行该程序。
2023-07-22 23:03:29 186
转载 转载:VTK笔记-裁剪分割-不规则闭合圈选裁剪-vtkSelectPolyData类(黑山老妖)
vtkClipClosedSurface类使用平面集合剪裁闭合曲面。
2022-06-26 18:27:03 1055
转载 转载:VTK笔记-裁剪分割-三维曲线或几何切割体数据(黑山老妖)
https://blog.csdn.net/liushao1031177/article/details/118419221
2022-06-26 13:58:04 1175 1
原创 Slicer的传输函数参数值
<?xml version="1.0" encoding="UTF-8"?><MRML> <VolumeProperty selected="false" hideFromEditors="false" name="CT-AAA" gradientOpacity="4 0 1 255 1" userTags="" specularPower="10" scalarOpacity="12 -3024 0 143.556 0 166.222 0.686275 214.389.
2022-05-29 18:37:35 142
原创 linux下抓取C++ throw调用栈
使用API钩子技术,抓取throw调用的调用堆栈。1. hook_cxa_throw-lys.hpp#pragma once#include <dlfcn.h>#include <cstddef>#include <exception>#include <signal.h>#include <execinfo.h>#include <ucontext.h>#include <thread>#i
2022-05-25 22:16:26 500
原创 C++ 并发编程练习15 “最简单的线程池”
下面的代码展示了一个简单的线程池。#include <atomic>#include <functional>#include <iostream>#include <mutex>#include <queue>#include <thread>#include <vector>template<typename T>class thread_safe_queue{private:
2022-05-02 16:32:59 981
原创 C++并发编程练习14 “异步任务测试”
使用feature特性,可以获得异步执行的效果。如下面的例子#include <iostream> #include <future> #include <chrono> #include <thread> int loopType (int from, int to) { for (int i = from; i != to; ++i) { std::cout <
2022-05-02 15:13:10 931
原创 在Linux Deepin OS 下编译ParaView的步骤
首先编译OPEN-MPIgit clone https://github.com/open-mpi/ompi.gitcd ./ompigit submodule update --init --recursivesudo apt-get install autoconfsudo apt-get install libtoolsudo apt-get install flex./autogen.pl./confiugremake再下载ParaView源代码git clone h..
2022-04-30 14:54:53 481 3
原创 在Windows/QT环境编程中同时catch C++异常和SEH异常
代码如下://.hclass CONTROLLER_API CExceptionGuard{public: CExceptionGuard(); ~CExceptionGuard();private: class Impl; Impl* prd;};// .cppclass SE_Exception : public std::exception{private: const unsigned int nSE;public: SE_Exception() noe
2022-04-28 12:10:40 1782
原创 在Windows中编译libevent库步骤
1. 从下面的网页中下载和安装 Win64OpenSSL-1_1_1n.msi , 全部照缺省设置安装即可Win32/Win64 OpenSSL Installer for Windows - Shining Light Productions (slproweb.com)2. 到git下载libevent库https://github.com/libevent/libevent.git33. CMake配置libevent项目勾选 EVENT__DISABLE_MBEDTLSOPE
2022-04-27 00:12:38 1734
原创 DLL远程注入一则
1. 线程注入一注入的可行性 kernel32.dll 和 user32.dll 是两个在大部分程序上都会调用的 DLL 同一个 DLL,在不同的进程中,不一定被映射(加载)在同一个内存地址下。但是 kernel32.dll和 user32.dll 例外。他们总是被映射到进程的内存首选地址因此,在所有使用这两个 DLL 的 进程中,这两个 DLL 的内存地址是相同的。我们在本进程获取的 kernel32.dli 中函数的地址, 在目标进程中也是一样的。2. 涉及的 API OpenProce
2022-04-24 00:14:24 279
原创 C++并发编程练习13 “线程安全栈设计”
使用mutex锁,设计一个线程安全的stack,示例如下#include <exception>#include <memory>#include <mutex>#include <stack>struct empty_stack : std::exception{ const char* what() const throw();};template<typename T>class threadsafe_sta
2022-04-23 17:57:56 710
原创 C++并发编程练习12 “在跨线程中使用函数对象(指针)”
需要谨慎防止被保护的对象意外泄露到外界函数被更改状态。代码示例如下:#include <functional>#include <iostream>#include <mutex>#include <string>#include <thread>struct TData{public: int n; std::string str;public: TData() { n = 0; str = "Mout
2022-04-23 16:28:19 891
原创 C++并发编程练习11 “互斥量”
在多线程开发中,常遇到共享数据需要保护的问题,我们可以使用互斥量std::mutext类来解决这个问题,示例如下#include <chrono>#include <iostream>#include <mutex>#include <thread>#include <vector>struct scoped_mutex{ scoped_mutex(std::mutex& mtx) : mt(mt
2022-04-23 15:14:13 548
原创 C++并发编程练习10 “线程管理之线程ID”
std::thread有一个get_id()函数可以唯一标识系统中线程。示例如下#include <chrono>#include <iostream>#include <string>#include <thread>#include <vector>std::thread::id master;void func(int i){ std::string msg = std::to_string(i);
2022-04-23 00:10:48 940
原创 C++并发编程练习09 “线程管理之线程数目动态确定”
我们可以动态计算并创建合理的线程数目, 代码示例如下#include <algorithm>#include <functional>#include <iostream>#include <numeric>#include <thread>#include <vector>template<typename Iterator, typename T>struct accumulate_block{
2022-04-22 23:50:12 144
原创 C++并发编程练习08 “线程管理之线程容器”
我们可以使用容器保存一组线程,如下面的vector装入一组线程:#include <chrono>#include <iostream>#include <string>#include <thread>#include <vector>void func(int n){ std::string str = std::to_string(n); str += '\n'; std::cout <<
2022-04-22 22:40:44 329
原创 C++并发编程练习07 “线程管理之线程scoped”
线程scoped在某些场合还是很有用的,可以简化编程,不易出错。示例如下:#include <exception>#include <iostream>#include <thread>struct scoped_thread{ std::thread th; scoped_thread(std::thread&& t) { if (!t.joinable()) throw std::runtime_error("threa
2022-04-22 22:19:32 228
原创 C++并发编程练习06 “线程管理之线程对象转移“
线程对象可以和一般对象一样,其所有权可以被转移,示例如下:#include <iostream>#include <thread>void get(std::thread&& t){ t.detach(); int a; std::cin >> a; std::cout << a << std::endl;}void task(const char* sz){ std::cout << s
2022-04-22 22:03:47 227
原创 C++并发编程练习05 “线程管理之传递引用参数给任务函数与std::ref绑定”
传递引用时需注意,如下面代码注释中所述:#include <iostream>#include <thread>void task(int& n){ n *= 2;}int main(){ int a = 100; //注意必须用std::ref绑定,否则由于thread构造函数无法识别,它将传入a的副本的引用给task函数 std::thread t(task, std::ref(a)); t.join()
2022-04-22 20:31:57 263
原创 C++并发编程练习04 “线程管理之传递参数给任务函数”
我们可以对不同的多线程任务函数传递对应参数。其参考代码如下:#include <iostream>#include <thread>void task(int n, const char* message){ std::cout << n << "," << message << std::endl;}int main(){ std::thread t(task, 1, "something hap
2022-04-22 20:17:08 277
原创 C++并发编程练习03 “线程管理之线程守卫”
包装类对象析构时执行线程#include <iostream>#include <thread>struct thread_guard{public: std::thread& t; explicit thread_guard(std::thread& _t) : t(_t) {}; ~thread_guard() { if(t.joinable()) t.join(); } thread_guard(thread_guard&
2022-04-22 10:26:31 195
原创 C++并发编程练习02 “线程管理之启动线程”
启动线程有detach()和join()两个函数,前者是异步启动,后者是同步启动并等待结束。#include <iostream>#include <thread>struct task{ int& i; task(int& i_) :i(i_) {}; void operator()() { for (int j = 0; j < 200; j++) std::cout
2022-04-22 10:12:38 123
原创 C++并发编程练习01 “Hello World“
#include <iostream>#include <thread>void sayHello(){ std::cout << "Hello World!\n";}int main(){ std::thread t(sayHello); t.join(); return 0;}
2022-04-22 10:05:50 123
原创 使用批处理文件递归删除C++项目中的.git文件夹和VC生成文件
使用.bat文件可以方便的进行如标题所示的文件。.bat文件的内容可以象下面这样@echo Offdel /F /s /a *.suo *.dll *.exe *.sha512 *.db *.ncb *.user *.pdb *.netmodule *.aps *.ilk *.plg *.opt *.idb *.obj *.sbr *.exp *.tlh *.tli *.clw *.pch *.res *.sdf *.ipch *.log *.tlogsetlocal enabledela
2022-04-20 17:57:00 348
TxtScript- C/CPP语法着色编辑器
2013-01-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人