Go Down

Topic: byte array and header file (Read 4904 times) previous topic - next topic

kyrpav

i want to set a mac address on a header file and initialize it.

i can not type
Code: [Select]

bla bla bla
public:
byte mac[]={0x00, 0xAA,0xBB, .....};

it does not let me it give me syntax error. I can only delete this declaration and give it once at the .cpp file.
it also asks to make it static but it does not work also.
Well propably there are many solutions but i want to initialize a byte array at the header file. is it possible.

PaulS

Quote
i want to set a mac address on a header file and initialize it.

What you want to do and what you can do are not the same. Header files are for declaring variables. Source files are for valuing variables.

Quote
is it possible.

No.

kyrpav

i get syntax error for

Code: [Select]
byte const mac[]={....};

but i do not  get error for

Code: [Select]
static const unsigned int localport=8888;

this is also initialization and it has no syntax error.

Also if i declare the array at .h file i can not use the above syntax to initialize it at the .cpp file i have to set each index one by one. I can tho just
declare and initialize by ones at .cpp tho.

PaulS

Quote
i get syntax error for

Then, don't do that.

Quote
Also if i declare the array at .h file i can not use the above syntax to initialize it at the .cpp file i have to set each index one by one.

Welcome to reality.

Go Up