Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expected ‘;’ before numeric constant

Tags:

c

When compiling the following program, I get the error expected ‘;’ before numeric constant . What am I doing wrong?

#include <stdio.h>

#define GPIOBase 0x4002 2000

uint32_t * GPIO_type(char type);

int main(void)
{
    GPIO_type('G');

    return 0;
}

uint32_t * GPIO_type(char type)
{
    return (uint32_t *) GPIOBase;
}
like image 504
Randomblue Avatar asked Feb 19 '26 22:02

Randomblue


1 Answers

The problem is:

#define GPIOBase 0x4002 2000

And where you use it:

return (uint32_t *) GPIOBase;

becomes:

return (uint32_t *) 0x4002 2000;

Which is a compiler error. There's a stray 2000 lingering after your 0x4002. I suspect you want:

#define GPIOBase 0x40022000

like image 169
Moo-Juice Avatar answered Feb 22 '26 14:02

Moo-Juice