Wednesday 2 October 2013

use extern in C

use extern in C

I try to use some global variable in my project, but don't work. I
declared my variable like this:
In file kernel.h :
extern DBConnection * conn;
And, in my other file, called kernel.c, i do this:
#include "kernel.h"
int get_info() {
conn = (DBConnection *) malloc(sizeof(DBConnection));
}
But, at compile, i received an error that is:
/home/fastway/VFirewall-Monitor/kernel.c:19: undefined reference to `conn'
What i'm doing wrong?
Thanks.

No comments:

Post a Comment