2011-02-27 5 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

관련 문제