简 述:std::vector 中的元素进行去重,其中元素为自定义结构体类型。提供三种思路,并且附上详细示例和分析。关键词内容:

  1. C++ std::unique 函数去重,却导致的 std::vector 发生改变(遇内存泄漏)
  2. c++ std::vector 利用 std::set 去重(自定义结构体创建 set 对象的方法)
  3. 自定义结构体在 sortunique比较 / 等于 函数书写(重载、函数、函数对象;严格弱序、相等)
Visual StudioC++11/17/20

**简 述: ** CMake 设置 Target 输出目录和后缀名

set(EXECUTABLE_OUTPUT_PATH                      "xxx/path")        		# 可执行文件的输出目录
set(LIBRARY_OUTPUT_PATH                         "xxx/path")        		#    库文件的输出目录

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG        "xxx/path")        		# debug   可执行文件的输出目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE      "xxx/path")        		# release 可执行文件的输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG        "xxx/path")       		# debug      库文件的输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE      "xxx/path")       		# release    库文件的输出目录
set(CMAKE_DEBUG_POSTFIX                         "xxx/path")       		# debug        库文件的后缀名
set(CMAKE_RELEASE_POSTFIX                       "xxx/path")       		# release      库文件的后缀名

set_target_properties(${TARGET_NAME} PROPERTIES DEBUG_POSTFIX "_d")     # debug      可执行文件的后缀名
set_target_properties(${TARGET_NAME} PROPERTIES RELEASE_POSTFIX "_r")   # release   可执行文件的后缀名

简 述: Windows 编程中常见的一些类型意义、区别和讲解定义

  1. PVOID 和 LPVOID
  2. LPSTR / LPCSTR / LPTSTR / LPCTSTR / LPWSTR / LPCWSTR
  3. HWND / HANDLE / HMODULE / HINSTANCE

辨别区分标志

  • L –> long;WIN32 下 long 和 int 长度一样。 故 L 和 LP 无区别
  • C –> const
  • T –> 通用版本,依据 UNICODE 时候被定义,确定使用 A 还是 W 版本的函数、或字符集。
  • STR –> string 字符串
  • PTR –> ptr 指针

Windows 编程

简 述: 哇卡卡卡,这次又抓到了 Microsoft win10 的 🐛,这次还影响到了我写代码哦🙄。项目使用 Release X86 编译会成功,而切换到 Release X64 编译会失败。

Error (active) E0147 declaration is incompatible with “BOOLEAN _BitScanForward” (declared at line 2825 of “C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winnt.h”) C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\intrin0.inl.h 123

Error C2007 #define syntax C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h 38
Error C2144 syntax error: ‘int’ should be preceded by ‘;’ C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h 43
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h 43

Visual Studio调试