1. Release下进行Debug调试
- 工程属性 -> C/C++ -> 常规 -> 调试信息格式 -> 程序数据库(/Zi)
- 工程属性 -> C/C++ -> 优化 -> 优化 -> 已禁用(/Od)
- 工程属性 -> 链接器 -> 调试-> 生成调试信息 -> 优化以便于调试(/DEBUG)
2. 动态库源码调试
- 添加动态库工程至当前解决方案
- 动态库工程:工程属性 -> 调试 -> 命令 -> 选择调用该动态库的可执行文件
- 设置动态库工程为可调式模式(Debug生成dll或者可调式模式Release下生成dll)
- 拷贝dll到调用目录下
3. 编程规范
- 变量初始化,不同编译器有不同的默认初始化,为避免出错,建议使用的变量都进行初始化为宜;
4.对于文件编码为utf-8报错或者警告的处理
程属性 -> C/C++ -> 所有选项-> 附加选项 -> /utf-8
附加文件格式转化脚本:
忘记在哪儿copy的了,如有侵权请告知
# coding utf-8
import os
import chardet
# 获得所有指定文件的路径,传入根目录路径
def find_all_file(path: str) -> str:
for root, dirs, files in os.walk(path):
for f in files:
if f.endswith('.h'):
fullname = os.path.join(root, f)
yield fullname
pass
pass
pass
# 判断是不是utf-8编码方式
def judge_coding(path: str) -> dict:
# with open('utf.txt', 'rb') as f: # 删除就行
# utf = chardet.detect(f.read()) # 同上
with open(path, 'rb') as f:
c = chardet.detect(f.read())
if c != 'utf-8': # 改为 c != 'utf-8'
return c
# 修改文件编码方式
def change_to_utf_file(path: str):
for i in find_all_file(path):
c = judge_coding(i)
if c:
change(i, c['encoding'])
print("{} 编码方式已从{}改为 utf-8".format(i, c['encoding']))
def change(path: str, coding: str):
with open(path, 'r', encoding=coding) as f:
text = f.read()
with open(path, 'w', encoding='utf-8') as f:
f.write(text)
# 查看所有文件编码方式
def check(path: str):
for i in find_all_file(path):
with open(i, 'rb') as f:
print(chardet.detect(f.read())['encoding'], ': ', i)
def main():
my_path = './'
change_to_utf_file(my_path)
# check(my_path)
if __name__ == '__main__':
main()
5.校时问题
校时涉及到用户权限问题,不同操作系统处理方式不同
/* 获取时区和时间设置权限,前提是当前用户具有相应的权限,否则返回false。权限查询与设置:本地安全策略->用户权限分配->更改时区/更改系统时间 */
bool enableSetTimePriviledge