I have the below struct in my program.
typedef unsigned char BYTE;
struct data
{
BYTE a;
BYTE b;
BYTE c;
};
some lines late..... I create an instance of the struct
data buffer[100][100];
later in the program I have to typecast the "buffer" instance to char * in order to be used by another function.
int bmp_generator(char *filename, int width, int height, BYTE* data)
{
BITMAPFILEHEADER bmp_head;
BITMAPINFOHEADER bmp_info;
int size=width*height*3;
bmp_head.bfType=0x4D42;
bmp_head.bfSize=size + sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER);
bmp_head.bfReserved1=bmp_head.bfReserved2=0;
bmp_head.bfOffBits=bmp_head.bfSize-size;
bmp_info.biSize=40;
bmp_info.biWidth=width;
bmp_info.biHeight=height;
bmp_info.biPlanes=1;
bmp_info.biBitCount=24;// bits per pixel
bmp_info.biCompress=0;
bmp_info.biSizeImage=size;
bmp_info.biXPelsPerMeter=0;
bmp_info.biYPelsPerMeter=0;
bmp_info.biClrUsed=0;
bmp_info.biClrImportant=0;
FILE *fp;
if (!(fp=fopen(filename,"wb"))) return 0;
fwrite(&bmp_head,1, sizeof(BITMAPFILEHEADER), fp);
fwrite(&bmp_info,1,sizeof(BITMAPINFOHEADER), fp);
fwrite (data, 1, size, fp);
fclose(fp);
return 1;
}
[some lines later]
bmp_generator("./test.bmp", 512, 512, (BYTE*)buffer);
However, when I run the above code the gcc compiler gives me a warning saying "warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]"
can someone help me out with this. Thanks in Advance.