//gcc 7.4.0
#include <stdio.h>
#define LONG_TO_BUF(long,buf) {buf[0] = (long&0xff000000) >> 24;\
buf[1] = (long&0x00ff0000) >> 16;\
buf[2] = (long&0x0000ff00) >> 8;\
buf[3] = (long&0x000000ff);}
int main(void)
{
unsigned char mydata[4] = {0};
long num = 0xaabbccdd;
LONG_TO_BUF(num,mydata);
printf("0x%x\n",mydata[0]);
printf("0x%x\n",mydata[1]);
printf("0x%x\n",mydata[2]);
printf("0x%x\n",mydata[3]);
return 0;
}