I have a function in my header file 1t.h that looks like the following:
extern int dthreads_libinit(dthreads_func_t func, void *arg);
I then want to implement that function in a separate file which includes 1t.h:
int dthreads_libinit(dthreads_funct_t func, void* arg) {
//Do something here...
}
I get these errors though:
‘int dthreads_libinit’ redeclared as different kind of symbol'
error: previous declaration of ‘int dthreads_libinit(dthreads_func_t, void*)
What is wrong with what I am doing?
You have a typo in the signature of your function definition
dthreads_libinit(dthreads_funct_t func, void* arg) {
// ^
If you correct this to
dthreads_libinit(dthreads_func_t func, void* arg) {
as it's used for the func
param in the function declaration
extern int dthreads_libinit(dthreads_func_t func, void *arg);
the code compiles fine (no matter, wether g++
or gcc
is used).