See Using array init list as temporary in C++11? Using array init list as temporary in C++11?
You can solve it by using const
. This compiles:
char a[8];
void cpaddr(char target[], const byte *source) {
int i;
for (i=0; i<8; i++)
target[i] = source[i];
}
int main() {
byte b[] = {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D};
cpaddr(a, b);
cpaddr(a, (const byte[]) {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D});
}
Note I had to change your array from char
to byte
because I was getting (valid) warnings that things like 0xCA don't fit into a char.
See Using array init list as temporary in C++11?
You can solve it by using const
. This compiles:
char a[8];
void cpaddr(char target[], const byte *source) {
int i;
for (i=0; i<8; i++)
target[i] = source[i];
}
int main() {
byte b[] = {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D};
cpaddr(a, b);
cpaddr(a, (const byte[]) {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D});
}
Note I had to change your array from char
to byte
because I was getting (valid) warnings that things like 0xCA don't fit into a char.
See Using array init list as temporary in C++11?
You can solve it by using const
. This compiles:
char a[8];
void cpaddr(char target[], const byte *source) {
int i;
for (i=0; i<8; i++)
target[i] = source[i];
}
int main() {
byte b[] = {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D};
cpaddr(a, b);
cpaddr(a, (const byte[]) {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D});
}
Note I had to change your array from char
to byte
because I was getting (valid) warnings that things like 0xCA don't fit into a char.
See Using array init list as temporary in C++11?
You can solve it by using const
. This compiles:
char a[8];
void cpaddr(char target[], const byte *source) {
int i;
for (i=0; i<8; i++)
target[i] = source[i];
}
int main() {
byte b[] = {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D};
cpaddr(a, b);
cpaddr(a, (const byte[]) {0x00, 0x10, 0xFF, 0xCA, 0x00, 0x00, 0xA2, 0x7D});
}
Note I had to change your array from char
to byte
because I was getting (valid) warnings that things like 0xCA don't fit into a char.