小编Nos*_*Nos的帖子

如何折叠带有预处理器的控制语句?

最近,我一直在处理一些同事的一些遗留代码,使用 Visual Studio 代码我已经能够将其转换为清晰且可读的 C 格式。然而,我想折叠一些控制语句,因为我的同事编写的控制语句有时会超过 100 行。

在这些行中,我添加了预处理器控制语句来启用和禁用我的更改。

在 Visual Studio 代码中,我能够很好地折叠代码,但是一旦遇到预处理器语句(至少是 #ifdef 和 #ifndef),它就会停止。由于大约每 10 行中有 1 行要折叠一个控制语句,我需要折叠 10 次,这有点打败了它背后的想法,对吗?

我尝试在设置和一些谷歌搜索中寻找折叠和折叠,但我找不到任何可以解决我的问题的东西。

例如我有这个片段

if(true)
{
    Some functions();
#ifdef DEBUG
    Functions with debugging only();
#else
    Functions without debugging only();
#endif
    Some other functions();
}
Run Code Online (Sandbox Code Playgroud)

我希望,每当我折叠 if(true) 时,该控制语句中的所有内容都会被折叠。这是我习惯的,也是在 Eclipse 中 vs2017 中会发生的情况。这在 VSCODE 中不会发生!而只是一些函数();被折叠。

如何使 VSCODE 折叠行为与其他 IDE 类似?

c preprocessor folding visual-studio-code

5
推荐指数
1
解决办法
1239
查看次数

如何强制链接器将字符串数组的const数组存储到flash(而不是RAM)中

最近我收到了一些有一些问题的遗留代码.在一些代码中,我注意到许多状态报告存储为3d char数组.踢球者是很多这个空间实际上是未使用过的.例如:

const char txt[<60>][6][150] =
{
    {"This is a very very long string of text", "The others are empty", "", "", "", ""},
    {"The text is different, but similarly a lot of unused space", etc...}
};
Run Code Online (Sandbox Code Playgroud)

(60不存在,但有60个条目).

然后使用以上声明通过QSPI将此代码放入闪存中

__attribute__((section(".ExtQSPIFlashSection")))
Run Code Online (Sandbox Code Playgroud)

此部分在链接器中定义如下:

QSPI (rx)       : ORIGIN = 0x90000000, LENGTH = 64M
.ExtQSPIFlashSection : { *(.ExtQSPIFlashSection) } >QSPI
Run Code Online (Sandbox Code Playgroud)

作为一种更有效的内存方法,我想重写它:

const char **txt[] =
{
    (const char*[]) {"This is a very very long string of text", "The others are empty", "", "", "", …
Run Code Online (Sandbox Code Playgroud)

c embedded linker arm stm32

3
推荐指数
2
解决办法
152
查看次数

标签 统计

c ×2

arm ×1

embedded ×1

folding ×1

linker ×1

preprocessor ×1

stm32 ×1

visual-studio-code ×1