Home:ALL Converter>Function declaration with struct parameter in header file in C

Function declaration with struct parameter in header file in C

Ask Time:2018-03-16T17:51:52         Author:J. Doe

Json Formatter

My teachers words "Create a header file and put all function declarations of the functions you have in your .c file. Also put your structs and macros in the header. Make sure to "protect" this file from being included multiple times"

Okay so I protect my header by using

#ifndef List_h
#define List_h
//My header code
#endif

I have put all my structs in this header file and included it in my .c files and everything seem to work fine. I do not use any macros so I do not have that. The problem comes when I try to do my function declaration. This is what my function looks like:

int FunctionName(struct NameOfStruct *PointerToStruct){
//Code here
}

I have then tried to declare my function in the header file like this:

int FunctionName(struct);

But get an error "Declaration of 'struct NameOfStruct' will not be visible outside of this function"

I have tried:

int FunctionName(struct NameOfStruct *PointerToStruct);

but get the same error. How I am supposed to declare a function in the header file? Nothing I have found on google seem to work. What am I doing wrong?

Author:J. Doe,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/49317635/function-declaration-with-struct-parameter-in-header-file-in-c
yy