Arthur Tumanyan wrote:
> 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'
It looks like the #include <mysql.h> isn't being included at all -
perhaps there is another header.h file on your system path?
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/