Hello I have small problem with followed C code:
//Hardcoded commands:
#define someCommand 0x1223;
#(...)
//functions definitions:
void socketWrite(uint8_t address, const uint8_t *data, size_t length);
//main task
int main(){
//I want send someCommand to socket
socketWrite(0xff, &someCommand, 1);
(...)
}
this code give me of course compilation error:
error: ‘someCommand’ was not declared in this scope
but my question is about how write this correctly without creating new buffer data that can handle this command like this:
uint8_t * buff;
*buff = someCommand;
socketWrite(0xff, buff, 1);
someCommandis a #define. The C preprocessor generates a source text by replacing it by its value.So your code looks like:
Taking address of 0x1223 isn’t possible.
may works
otherwise:
and later