How to share struct within functions; (warnings: expected 'struct <anonymous> **')

I don't understand why this happens. I can call the read_png_file and *data is there. But when I call next function so there is no data in there but it is type
(PNGDataPtr *) 0x22ff24 refering to (PNGDataPtr) 0x77c02850 <msvcrt!??9type_info@@QBEHABV0@@Z+5208> Can you explain what happens there and how correct it? I want to pass the struct and share it between functions.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <stdlib.h>
#include <png.h>

typedef struct
{
	FILE *fp;
} PNGData, *PNGDataPtr;


void read_png_file(char* file_name, PNGData * data)
{
}

void write_png_file(char* file_name, PNGDataPtr * data)
{
}

void process_file(PNGDataPtr * data)
{
}

int main(int argc, char **argv)
{
    PNGData data;
    read_png_file(argv[1], &data);
    process_file(&data);
    write_png_file(argv[2], &data);
    return 0;
}


function 'main':|
warning: passing argument 1 of 'process_file' from incompatible pointer type
main.c|19|note: expected 'struct <anonymous> **' but argument is of type 'struct PNGData *'|
warning: passing argument 2 of 'write_png_file' from incompatible pointer type [enabled by default]|
15|note: expected 'struct <anonymous> **' but argument is of type 'struct PNGData *'|


NOTE:
I have removed content of the functions to make it as short as possible. The data variable was filled with values originally but only in the read function.
Last edited on
process_file takes a PNGData** but you are passing a PNGData*.
Topic archived. No new replies allowed.