English 中文(简体)
初始化器元素不是编辑时的常数,而是编纂者 t错。
原标题:Initializer element is not a compile-time constant but compiler doesn t throw error

I m 学习嵌入式系统并实施startup.c文档。 在制作中断病媒表时,我在编辑上发现了以下错误(使用<代码>clangd<>/code>作为我的LSP):

“entertext

启动:c

#include <stdint.h>

#define SRAM_START 0x20000000U                
#define SRAM_SIZE (128U * 1024U)              
#define SRAM_END ((SRAM_START) + (SRAM_SIZE)) 
#define STACK_START SRAM_END 

int main(void);
void reset_handler(void);
/* more stuff */

uint32_t vectors[] __attribute__((section(".isr_vectors"))) = {
    STACK_START,
    (uint32_t)reset_handler,
    /* more stuff */
}

void reset_handler(void){
    /* .data, .text and .bss */
    main();
}

为什么这种热情能够编纂?

问题回答

为什么这种热情能够编纂?

病媒是一系列功能点。

typedef void (*const pHandler)(void);
__attribute__((section(".isr_vectors"), used)) 
pHandler vectors[] = {
    (pHandler)STACK_START,
    reset_handler,
};

为什么这种热情能够编纂?

编审员不需要reject任何特定代码。 要求他们传递一个诊断信息<>,说明每一项限制的违反情况,但即使是那些,他们也可以做他们想要做的事情。 不管怎么说:就标准而言,这种法典没有界定行为。 许多汇编者实施延伸,包括接受违反语言限制的守则。

顺便说一句,你所传递的信息令人误解。 所述表述的确不符合“惯用表述”的定义,也不符合任何其他类型的固定表述,即光谱明确允许在初始剂中出现静态或已读存储期的物体。 但是,如果没有投放权,它将成为“address persistent,这是在最初的制片人中允许的,因此,可以及时对投放物进行评价,特别是在为32条轨道结构进行汇编时。

因此,也认为,具体内容明确允许执行接受其他形式的经常表达。

我可以说,为什么你特别愿意接受该守则,但all,没有任何东西要求汇编者拒绝该守则,而对于某些执行情况来说,接受该守则是完全自然的。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...