【发布时间】:2016-07-29 08:56:29
【问题描述】:
在下面的代码中,我可以使用const uint32_t PERIPH_BASE_ADDR = 0x40000000; 代替#define 吗?
#ifndef MEMORY_MAP_H_
#define MEMORY_MAP_H_
#include <stdint.h>
// Base address for devices on the STM32F10x
#define PERIPH_BASE_ADDR ((uint32_t)0x40000000) // Peripheral base address in the alias region
// Peripheral memory map
#define AHB1_BASE_ADDR ((uint32_t)(PERIPH_BASE_ADDR + 0x20000)) // Advanced High-performance Bus 1
#endif /* MEMORY_MAP_H_ */
【问题讨论】:
-
你试过了吗?...
-
如果放在头文件中,应该使用
static const。 -
@blatinox:定义不应进入头文件!这是 C 语言,
const的语义与 C++ 不同。
标签: c microprocessors