[U-Boot] About the variable environment and default_environment when environment is embedded

Hi all,
I'm working with the u-boot-2009-08.tar.bz2 and find some code I am not very clear. My puzzle is about the extern array "environment[]" which declared in "env_flash.c" as an array composed by unsigned char. However, it is defined as a env_t struct in the "env_embedded.c". So the declaration conflicts with definition, but it can be compiled normally, does any one tell me why? Thanks.
Here is the code in ./common/env_flash.c and ./common/env_embedded.c
****************************************************************************** /* In file ./common/env_flash.c */
#ifdef ENV_IS_EMBEDDED
extern uchar environment[]; env_t *env_ptr = (env_t *)(&environment[0]);
#ifdef CMD_SAVEENV /* static env_t *flash_addr = (env_t *)(&environment[0]);-broken on ARM-wd-*/ static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR; #endif
#else /* ! ENV_IS_EMBEDDED */
env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR; #ifdef CMD_SAVEENV static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR; #endif
****************************************************************************** /* In file ./common/env_embedded.c */
#ifdef ENV_IS_EMBEDDED
...
env_t environment __PPCENV__ = { ENV_CRC, /* CRC Sum */ #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT 1, /* Flags: valid */ #endif { #if defined(CONFIG_BOOTARGS) "bootargs=" CONFIG_BOOTARGS "\0" #endif #if defined(CONFIG_BOOTCOMMAND) "bootcmd=" CONFIG_BOOTCOMMAND "\0" #endif
.....
};
...
#endif ******************************************************************************
participants (1)
-
Xiaojun Li