Hi!I have some troubles with variable declarations.
I can't access variables declared in included header file(s).
For instance:
----header file--------------
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <mysql.h>
#include <sys/types.h>
#include <time.h>
const char MYSQL_ERR[255];
.................etc
---------source file----------------------
#include "header.h"
int db_connect(char *dbhost,char *dbuser,char *dbpwd,char *dbname,unsigned
int dbport){
mysql_init(&mysql);
connection =
mysql_real_connect(&mysql,dbhost,dbuser,dbpwd,dbname,dbport,NULL,0);
/* check for connection error */
if(connection == NULL) {
/* log the error message */
snprintf(MYSQL_ERR,Q_LINE_MAXLEN,"%s\n",(char
*)mysql_error(&mysql));
log_debug(MYSQL_ERR); /* logger function */
return 1;
}
return 0;
}
--------------------------------------------
after compiling:
shaga.c: In function `db_connect':
shaga.c:13: warning: implicit declaration of function `mysql_init'
shaga.c:14: warning: implicit declaration of function `mysql_real_connect'
shaga.c:14: warning: assignment makes pointer from integer without a cast
shaga.c:18: error: `MYSQL_ERR' undeclared (first use in this function)
shaga.c:18: error: (Each undeclared identifier is reported only once
shaga.c:18: error: for each function it appears in.)
shaga.c:18: warning: implicit declaration of function `mysql_error'
--
View this message in context:
http://www.nabble.com/variable-declaration-don%27t-work-tf4072914.html#a11575264
Sent from the C-prog mailing list archive at Nabble.com.