Struct parametr in gcc function
I wrote the code and it works fine with the g ++ compiler, but when I use gcc it throws an error Unknow type name 'Image' in void load_image(FILE*, Image*);
Here is a portion of my header file:
struct Image {
struct FileHeader file_header;
struct InfoHeader info_header;
struct RGBQuads rgbquads;
struct Pixel** pixel;
struct Pixel* pixels_array;
};
void load_image(FILE*, Image*);
So I can't figure out what the problem is. I tried to write using C rules.
+3
source to share
2 answers
It seems that you are compiling the program as a C program. If so, you need to write
void load_image(FILE*, struct Image*);
Another approach is to use a typedef for the struct. for example
typedef struct Image {
struct FileHeader file_header;
struct InfoHeader info_header;
struct RGBQuads rgbquads;
struct Pixel** pixel;
struct Pixel* pixels_array;
} Image;
void load_image(FILE*, Image*);
+4
source to share