2011-02-27 107 views
0

人,mysql_row从不兼容的指针类型返回赋值?用C

看到下面的代码:

gboolean auto_refresh_host_list(bahan *unit) 
    { 
//assuming unit->setting->handle_conn has initiated and connected 
mysql_query(unit->setting->handle_conn,"select * from host"); 
unit->setting->handle_result = mysql_store_result(unit->setting->handle_conn); 

guint num_fields = mysql_num_fields(unit->setting->handle_result); 

line:148 while((unit->setting->handle_row = mysql_fetch_row(unit->setting->handle_result))) 
{ 
    guint i; 
    for(i=0; i<= num_fields; i++) 
    { 
    line:153 printf("%s", (unit->setting->handle_row[i] ? unit->setting->handle_row[i] : "NULL")); 
    } 
    printf("\n"); 
} 
mysql_free_result(unit->setting->handle_result); 
line:158} 

,但一旦我编译它表明这样的警告:

main.c:148: warning: assignment from incompatible pointer type 
main.c:153: warning: pointer type mismatch in conditional expression 
main.c:153: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘void * const’ 
main.c:158: warning: control reaches end of non-void function 

反正想成为的样子以下结构:

MYSQL *handle_conn; 
MYSQL_RES *handle_result; 
MYSQL_ROW *handle_row; 
MYSQL_FIELD *handle_field; 

我读一下后有点困惑http://zetcode.com/tutorials/mysqlcapitutorial/,好吧,任何人有任何想法?

回答

2

mysql_fetch_row()返回MYSQL_ROW,而不是一个MYSQL_ROW *

+0

我的歉意... – capede 2011-02-27 10:35:08