小编Moh*_*sam的帖子

在 C 中定义全局常量

如何在 C 中定义全局常量?我被告知要做这样的事情

在 header.h

const u32 g_my_const;
Run Code Online (Sandbox Code Playgroud)

在代码.c

#include "header.h"
const u32 g_my_const= 10U;
Run Code Online (Sandbox Code Playgroud)

但我收到一个编译错误:

错误:未初始化的 const 'g_my_const' [-fpermissive]

有人可以解释如何正确地做到这一点。

c declaration extern stdint

2
推荐指数
1
解决办法
4296
查看次数

标签 统计

c ×1

declaration ×1

extern ×1

stdint ×1