修复代码高亮

This commit is contained in:
2024-07-15 15:32:29 +08:00
parent b3c844ba2d
commit e033bc8291
+12 -12
View File
@@ -27,7 +27,7 @@
- 单字符的变量只在临时变量或循环的计数中使用
- 等到真正需要使用时再定义变量
``` c++
```cpp
// 错误示例
int a, b;
char *c, *d;
@@ -42,7 +42,7 @@
- 以小写字符开头,后续单词以大写开头
- 避免使用缩写
``` c++
```cpp
// 错误示例
short Cntr;
char ITEM_DELIM = '';
@@ -60,7 +60,7 @@
- 总是使用一个空行(不要空多行)
- 总是在每个关键字和大括号前使用一个空格
``` c++
```cpp
// 错误示例
if(foo){
}
@@ -72,7 +72,7 @@
- *&*&
``` c++
```cpp
char *x;
const QString &myString;
const char''' const y = "hello";
@@ -82,7 +82,7 @@
- 类型转换后不加空白
- 尽量避免C风格的类型转换
``` c++
```cpp
// 错误示例
char* blockOfMemory = (char* ) malloc(data.size());
@@ -94,7 +94,7 @@
- 基本原则:左大括号和语句保持在同一行:
``` c++
```cpp
// 错误示例
if (codec)
{
@@ -107,7 +107,7 @@
-
``` c++
```cpp
static void foo(int g)
{
qDebug("foo: %i", g);
@@ -119,7 +119,7 @@
- body中只有一行时不使用大括号
``` c++
```cpp
// 错误示例
if (address.isEmpty()) {
return false;
@@ -139,7 +139,7 @@
- 例外1:如果父语句跨多行,则使用大括号
``` c++
```cpp
// 正确
if (address.isEmpty() || !isValid()
|| !codec) {
@@ -149,7 +149,7 @@
- 例外2:在if-else结构中,有一处跨多行,则使用大括号
``` c++
```cpp
// 错误示例
if (address.isEmpty())
return false;
@@ -184,7 +184,7 @@ it;
- 如果控制语句的body为空,则使用大括号
``` c++
```cpp
// 错误示例
while (a);
@@ -196,7 +196,7 @@ it;
- 使用圆括号将表达式分组
``` c++
```cpp
// 错误示例
if (a && b || c)