Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

struct parametr in function gcc

Tags:

c

gcc

I wrote some code and works perfectly using g++ compiler, but when I use gcc, it throws an error Unknow type name 'Image' in void load_image(FILE*, Image*);

Here's a part 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 cant understand whats the problem. I was trying to write using C rules.

like image 518
PepeHands Avatar asked Mar 16 '26 11:03

PepeHands


1 Answers

It seems that you are compiling the program as a C program. If so then you have to write

void load_image(FILE*, struct Image*);

Another approach is to use typedef for the structure. 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*);
like image 63
Vlad from Moscow Avatar answered Mar 19 '26 01:03

Vlad from Moscow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!