아래 코드에서 #define
대신 const uint32_t PERIPH_BASE_ADDR = 0x40000000;
을 사용할 수 있습니까?C 언어 - #define 대신 const uint32_t를 사용할 수 있습니까
#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_ */
시도해 보셨습니까? ... – LPs
헤더 파일에 넣으면'static const'를 사용해야합니다. – blatinox
@blatinox : 정의가 헤더 파일에 들어 가지 않아야합니다! 이것은 C이며'const'는 C++과 다른 의미를가집니다. – Olaf