I have a struct that is throwing "dereferencing pointer to incomplete type" errors when I try to access its member functions. I didn't create the struct, my professor did, so I am reasonably sure that when accessed properly it will work perfectly. This is the code:
Pixel.h (Created by professor):
#ifndef PIXEL_H
#define PIXEL_H
#include <stdbool.h>
#include <stdio.h>
#define BYTES_PER_PIXEL 3
typedef struct
{
unsigned char R;
unsigned char G;
unsigned char B;
}Pixel;
Pixel.c (Also created by professor):
#include "Pixel.h"
bool readFromFile(FILE* inputFile, Pixel* newPxl)
{
// Irrelevant code
return false;
}
bmpFilter.c (main file) (Created by me):
#include <stdio.h>
#include <stdlib.h>
#include "Pixel.h"
int main(int argc, char* argv[])
{
// Irrelevant code, inputFile initialized
struct Pixel* pix;
pix = malloc(sizeof(pix));
pix->readFromFile(inputFile, pix);
}
Error:
bmpFilter.c: In function ‘main’:
bmpFilter.c:33:5: error: dereferencing pointer to incomplete type ‘struct Pixel’
pix->readFromFile(inputFile, pix);
The error is almost certainly in bmpFilter and I have been unable to find how to fix it thus far.