Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Quiss on November 04, 2011, 08:56:16 am

Title: Code completion problem with #define
Post by: Quiss on November 04, 2011, 08:56:16 am
Hi,

I've encountered a problem with the code below:

Code
#define GPIOA_BaseAddress       0x5000
#define GPIOA ((GPIO_TypeDef *) GPIOA_BaseAddress)

typedef struct GPIO_struct
{
  vu8 ODR; /*!< Output Data Register */
  vu8 IDR; /*!< Input Data Register */
  vu8 DDR; /*!< Data Direction Register */
  vu8 CR1; /*!< Configuration Register 1 */
  vu8 CR2; /*!< Configuration Register 2 */
}
GPIO_TypeDef;

void main()
{
for(;;)
{
(*(GPIO_TypeDef *) GPIOA_BaseAddress)-> // at this point, i can see structure member list
GPIOA-> // no CC when i use #define
}
}

I'm using CB with default settings, am i missing something here? (CB: svn build rev 7550, OS: Windows 7 32 bit)
Title: Re: Code completion problem with #define
Post by: ollydbg on November 04, 2011, 10:06:16 am
That's because CC does not do macro expansion on every identifier. (This takes a lot of time, as it does not have a full preprocessor)