This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do I get the bit address in Keil C

Hi,

I want to know the address of a bit variable.
For example:

bit gBit;
func()
{
  printf("%d", &gBit);
}
How do I know where the variable gBit is allocated by the linker in run time?

Parents
  • Of course it can be done in 8051 otherwise how the compiler initialize all the global bit variables before the main function is called?

    When your program is compiled and linked, Keil C will build a data structure called C_INITSEG. This data structure stores all the global variables that need to be initialized before the main function is called. So it also records all the addresses of bit variables that need to initialized before the main function is called. By using this address of the bit variable, it can give the bit variable initial value.

Reply
  • Of course it can be done in 8051 otherwise how the compiler initialize all the global bit variables before the main function is called?

    When your program is compiled and linked, Keil C will build a data structure called C_INITSEG. This data structure stores all the global variables that need to be initialized before the main function is called. So it also records all the addresses of bit variables that need to initialized before the main function is called. By using this address of the bit variable, it can give the bit variable initial value.

Children