Reputation: 3340
I'm trying to initialize const member variables in the member initialization list of the constructor.
I'm getting the following error:
error: declaration does not declare anything [-fpermissive]
const uint32_t LEDS
^
My code:
#include <unistd.h>
class BaseAddr {
public:
BaseAddr():
LEDS (0x41200000),
SW1 (0x41210000), // switch 1
SW2 (0x41220000), // switch 2
AXI_BRAM (0x40000000), // 128 registers
AXI_DUMMY (0x43c00000) // 16 registers, 4 lsb are connected with leds
{ /* nop */ }
virtual ~BaseAddr() {}
const uint32_t LEDS;
const uint32_t SW1;
const uint32_t SW2;
private:
const uint32_t AXI_BRAM;
const uint32_t AXI_DUMMY;
};
why is it giving this error?
Upvotes: 0
Views: 621
Reputation: 61900
I'm going to say you have a macro LEDS
somewhere defined as follows:
#define LEDS
Now your member declaration becomes:
const uint32_t;
This correctly triggers the error, as shown here.
Upvotes: 2
Reputation: 196
Its because header file is not included for uint32_t.
Use any of following header file stdint.h or cstdint
Upvotes: 0