Home:ALL Converter>C : differences between prototype declaration in header and function declaration for implementation?

C : differences between prototype declaration in header and function declaration for implementation?

Ask Time:2009-04-06T00:05:28         Author:claf

Json Formatter

I was wondering about little differences between declaration of function prototypes in headers and in .c files. I have a header with some prototype functions and a some .c files with real implementation of these functions. I made some changes in the header, only added "__restrict" qualifier (recognized by gcc). My question is do I have to put the "__restrict" qualifier in .c files to (currently the code compile so I guess the answer is no, but some precision would be appreciated).

Does this work for every C qualifier? Can I add some "const" or "volatile" in header without having to do the same in .c files?

currently in header :

int myfunc_gettype (const mytype *__restrict, int *__restrict);

and in implementation file :

int myfunc_gettype(const mytype *attr, int *type)

Author:claf,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/719189/c-differences-between-prototype-declaration-in-header-and-function-declaration
Thomas L Holaday :

With gcc 4.0.1, it depends on whether the const is pointless:\n\n// Who cares, compiles fine, but irks the maintenance programmer.\n\n// f.h\nint f(const int i);\n\n// f.c\nint f(int i) { return i += 42; }\n\n\n// No no no no Your Types Conflict gcc will not stand for it\n\n// f.h\nint f(const int *pi);\n\n// f.c\nint f(int *pi) { return (*pi)+= 42; }\n",
2009-04-05T16:27:01
yy