Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Writing array in to constexpr uint8_t array #100

Open
x225am opened this issue Feb 11, 2021 · 1 comment
Open

Writing array in to constexpr uint8_t array #100

x225am opened this issue Feb 11, 2021 · 1 comment

Comments

@x225am
Copy link

x225am commented Feb 11, 2021

Hi All,
I am trying to store array data in to a constant array. Is it possible?
In the examples in the DS2431 example we have this:
constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF};
An I would like to use data which I read from Arduino internal eeprom (or external i2c epprom) stored in the data array
For example I have:

byte ReadData[8]; // this I am reading from internal eeproom
ReadData[0]=0xAA;
ReadData[1]=0xAB;
ReadData[2]=0x10;
ReadData[3]=0x11;
ReadData[4]=0xBC;
ReadData[5]=0xBF;
ReadData[6]=0xCD;
ReadData[7]=0x2D;

constexpr uint8_t mem_dummy[] = {ReadData[0], ReadData[1], ReadData[2], ReadData[3], ReadData[4], ReadData[5], ReadData[6], ReadData[7]};

In this case after compilation I have next error on the compiler:
the value of 'ReadData' is not usable in a constant expression

Any way around it?
Thanks in advance.

@rikka0w0
Copy link
Contributor

rikka0w0 commented Nov 6, 2021

Just remove the 'constexpr' qualifier.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants