c - struct definition in header file: type defaults to 'int' -
i've construction declaration , definition in header file header.h
as:
#include <linux/slab.h> struct hello{ int a; char b; }; extern struct hello *hello;
in file1.c i've:
#include<header.h> struct hello *hello; hello=kmalloc(sizeof(struct hello), __gfp_repeat); kfree(hello); //just check later if 'hello' - hello=null; //-is initialized or not.
in file2.c i've:
#include<header.h>
the struct variable hello
used in file1.c
, file2.c
.
but while compiling error:
file1.c:3:1 error: type defaults 'int' in declaration of 'hello' [-werror=implicit-int] file1.c:4:1 error: conflicting types 'hello' file1.c:3:16 note: previous declaration of 'hello' here extern struct hello *hello;
i've never used variable definition in header file. searched online , got few sources. unable find wrong. lot of other errors there after originates due mentioned error.
edited include proper codes.
is this:
hello=kmalloc(sizeof(struct hello), __gfp_repeat);
really @ file-level scope that? can't have code outside function in c, expect different error message.
c struct kernel global-variables extern
No comments:
Post a Comment