c++冷知识

大佬们主页

笔记 CodeNotes
Linux底层/libevent/Muduo/汽车电子
狮锅艺https://promacanthus.netlify.app
git动画

GDB 调试技巧

GDB 调试技巧

Google C++ 编程规范

Google C++ 编程规范

Makefile

https://makefiletutorial.com/#makefile-cookbook

#CMake

cmake -H.  -Bbuild -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# -H 是 SetHomeDirectory 的意思,即sets the source directory for the project, 
# -B 是 Sets the binary directory 为 build 目录(若目录不存在,会自动创建)
# 打开 COMPILE_COMMANDS 选项,会生成 compile_commands.json
  #或者CMakefile.txt中 option(CMAKE_EXPORT_COMPILE_COMMANDS ON)

c++11 初始化列表

// 类成员中多维数组初始化0及大小
class Test {
public:
    vector<int> a{vector<int>(30,0)};
    vector<vector<int>> b{30, vector<int>(40,0)};
    vector<vector<vector<double>>> c{30,vector<vector<double>>(40,vector<double>(50, 0.0f))};
};

C++名词术语

类型退化 (decay):指当参数按值传递时发生的类型转换,例如原生数组会转换为指针,顶层修饰符例如 const 和 引用 会被忽略

查看‘编译器’宏定义

# 如:#define __SIZE_MAX__ 0xffffffffffffffffUL
#    #define __cplusplus 201402L
gcc -dM -E -x c++ /dev/null   
g++ -dM -E -x c++ /dev/null

查看编译器是否支持c++11/14/17/20/23 ?

g++ -std=c++11 -E - < /dev/null
g++ -std=c++14 -E - < /dev/null
g++ -std=c++17 -E - < /dev/null
g++ -std=c++2a -E - < /dev/null

查看 #include “xx” 和 #include 搜索顺序

gcc -v -E -x c++ -
#输出
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/9
/usr/include/x86_64-linux-gnu/c++/9
/usr/include/c++/9/backward
/usr/lib/gcc/x86_64-linux-gnu/9/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include

查看‘编译器’搜索头文件路径即include路径

echo | gcc   -x c   -v -E -
echo | g++   -x c++ -v -E -
echo | clang -x c++ -v -E -

neovim

# 1.下载稳定版本的源码
https://github.com/neovim/neovim/tags
# 2. 根据 readme.md 编译安装
make CMAKE_BUILD_TYPE=Release; sudo make install
# 3. 牛逼插件-1
https://github.com/LazyVim/LazyVim 教程 https://www.lazyvim.org/
# 3. 牛逼插件-2
https://www.lunarvim.org/zh-Hans/docs/installation
# 4. Node
curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh

Linux 终端控制符

控制终端显示效果,如前景背景色字体等

man console_codes
echo -e "\x1b[34m蓝色文字"             # 1b 对应ascii码是ESC
echo -e "\x1b[5mHello World\x1b[0m"  #不停闪烁的 Hello World

# 1.常用控制码
\x1b[0m         关闭所有属性
\x1b[1m         设置高亮度
\x1b[4m         下划线
\x1b[5m         闪烁
\x1b[7m         反显
\x1b[8m         消隐
\x1b[30m -- \x1b[37m  设置前景色
\x1b[40m -- \x1b[47m  设置背景色
\x1b[nA         光标上移n行
\x1b[nB         光标下移n行
\x1b[nC         光标右移n列
\x1b[nD         光标左移n列
\x1b[y;H        设置光标位置
\x1b[2J         清屏
\x1b[K         清除从光标到行尾的内容
\x1b[s         保存光标位置
\x1b[u         恢复光标位置
\x1b[?25l        隐藏光标
\x1b[?25h        显示光标

# 2.文字背景色彩数字: (颜色范围:40 - 49)
40:  黑色
41:  深红色
42:  绿色
43:  黄色
44:  蓝色
45:  紫色
46:  深绿色
47:  白色

# 3.文字前景色数字: (颜色范围: 30 - 39)
30:  黑色
31:  红色
32:  绿色
33:  黄色
34:  蓝色
35:  紫色
36:  深绿色
37:  白色

ubuntu 好用开源软件

TimeShift 系统回滚快照
FlameShot 截图: sudo apt install flameshot # or visit https://flameshot.org
	新建系统截图快捷键:名称:flameshot  命令:/usr/bin/flameshot gui  快捷键 Print
notepadnext 记事本
----------------------------------------------------------------
数据库 https://github.com/beekeeper-studio/beekeeper-studio
# Install our GPG key
curl -fsSL https://deb.beekeeperstudio.io/beekeeper.key | sudo gpg --dearmor --output /usr/share/keyrings/beekeeper.gpg \
  && sudo chmod go+r /usr/share/keyrings/beekeeper.gpg \
  && echo "deb [signed-by=/usr/share/keyrings/beekeeper.gpg] https://deb.beekeeperstudio.io stable main" \
  | sudo tee /etc/apt/sources.list.d/beekeeper-studio-app.list > /dev/null

# Update apt and install
sudo apt update && sudo apt install beekeeper-studio -y

Open Source Beekeeper Studio

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值