免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4437 | 回复: 3
打印 上一主题 下一主题

请教:到底是load_defaults 还是load_default [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-03-12 01:40 |只看该作者 |倒序浏览
#include <stdio.h>
#include <mysql.h>

char *groups[]={"client",NULL};

int
main(int argc, char **argv)
{
        int i;

        my_init();

        printf("origianl argument vector:\n");
        for(i=0;i<argc;i++)
                printf("arg %d:%s",i,argv[i]);

        load_default("my",groups,&argc,&argv);

        printf("modefied:=n");

        for(i=0;i<argc;i++)
                printf("arg %d :%s\n",i,argv[i]);

        exit(0);
}



这个程序是《mysql网络编程〉〉中的

我用load_defaults编译报下面错误:

show_argv.c: In function `main':
show_argv.c:17: warning: passing arg 2 of `load_defaults' from incompatible pointer type


用load_default编译能通过
但是运行时却又不行了

请各位知道的,指点以下!!!!



还有这个方法到底是哪个头文件中的阿
感激不尽!!!!!

论坛徽章:
0
2 [报告]
发表于 2007-03-12 17:27 |只看该作者
It is necessary for my_init() to be called early in the initialization phase of a program's use of the MySQL library. However, my_init() is automatically called by mysql_init(), mysql_library_init(), mysql_server_init(), and mysql_connect(). If you ensure that your program invokes one of those functions before any other MySQL calls, there is no need to invoke my_init()  explicitly.

To access my_init(), your program must include the my_sys.h header file:

你确定自己有必要直接调用 my_init 而不使用 mysql_init? 我编译后,直接使用 my_init 的代码运行时导致一个错误

这两个函数声明都在 my_sys.h里面,自己看是哪个名称,佩服你的编译器,不可达的外部调用都允许

论坛徽章:
0
3 [报告]
发表于 2007-03-12 17:47 |只看该作者

回复 2楼 Namelessxp 的帖子

我是刚接触mysql
我刚才又编译了一次  确实 用的是my_init()
报错还是上面的那个错

我把my_sys.h头文件加进去,
却报下面的错

/usr/local/include/mysql/my_sys.h:557: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:558: error: syntax error before "my_register_filename"
/usr/local/include/mysql/my_sys.h:558: error: syntax error before "fd"
/usr/local/include/mysql/my_sys.h:560: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:561: error: syntax error before "my_create"
/usr/local/include/mysql/my_sys.h:562: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:562: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:563: error: syntax error before "Filedes"
/usr/local/include/mysql/my_sys.h:564: error: syntax error before "my_dup"
/usr/local/include/mysql/my_sys.h:564: error: syntax error before "file"
/usr/local/include/mysql/my_sys.h:564: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:565: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:566: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:567: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:568: error: syntax error before "my_create_with_symlink"
/usr/local/include/mysql/my_sys.h:570: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:570: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:571: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:572: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:573: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:574: error: syntax error before "Filedes"
/usr/local/include/mysql/my_sys.h:575: error: syntax error before "Filedes"
/usr/local/include/mysql/my_sys.h:577: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:578: error: syntax error before "my_seek"
/usr/local/include/mysql/my_sys.h:578: error: syntax error before "fd"
/usr/local/include/mysql/my_sys.h:578: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:579: error: syntax error before "my_tell"
/usr/local/include/mysql/my_sys.h:579: error: syntax error before "fd"
/usr/local/include/mysql/my_sys.h:579: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:580: error: syntax error before "Filedes"
/usr/local/include/mysql/my_sys.h:582: error: syntax error before "Filedes"
/usr/local/include/mysql/my_sys.h:584: error: syntax error before "byte"
/usr/local/include/mysql/my_sys.h:585: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:587: error: syntax error before "my_fseek"
/usr/local/include/mysql/my_sys.h:587: error: syntax error before "my_off_t"
/usr/local/include/mysql/my_sys.h:587: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:588: error: syntax error before "my_ftell"
/usr/local/include/mysql/my_sys.h:588: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:588: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:590: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:592: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:593: error: syntax error before "_VARARGS"
/usr/local/include/mysql/my_sys.h:594: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:596: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:598: error: syntax error before "_my_strdup"
/usr/local/include/mysql/my_sys.h:599: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:599: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:602: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:628: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:629: error: syntax error before "Filedes"
/usr/local/include/mysql/my_sys.h:630: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:631: error: syntax error before "fd"
/usr/local/include/mysql/my_sys.h:632: error: syntax error before "fd"
/usr/local/include/mysql/my_sys.h:633: error: syntax error before "_VARARGS"
/usr/local/include/mysql/my_sys.h:634: error: syntax error before "_VARARGS"
/usr/local/include/mysql/my_sys.h:639: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:640: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:641: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:646: error: syntax error before "my_filename"
/usr/local/include/mysql/my_sys.h:646: error: syntax error before "fd"
/usr/local/include/mysql/my_sys.h:646: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:660: error: syntax error before "sig_handler"
/usr/local/include/mysql/my_sys.h:660: error: syntax error before ')' token
/usr/local/include/mysql/my_sys.h:661: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:667: error: syntax error before "name"
/usr/local/include/mysql/my_sys.h:668: error: syntax error before "fn_ext"
/usr/local/include/mysql/my_sys.h:668: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:669: error: syntax error before "fn_same"
/usr/local/include/mysql/my_sys.h:669: error: syntax error before "toname"
/usr/local/include/mysql/my_sys.h:669: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:670: error: syntax error before "fn_format"
/usr/local/include/mysql/my_sys.h:670: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:671: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:672: error: syntax error before "strlength"
/usr/local/include/mysql/my_sys.h:672: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:673: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:674: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:675: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:676: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:677: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:678: error: syntax error before "intern_filename"
/usr/local/include/mysql/my_sys.h:678: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:678: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:679: error: syntax error before "directory_file_name"
/usr/local/include/mysql/my_sys.h:679: error: syntax error before "dst"
/usr/local/include/mysql/my_sys.h:679: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:680: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:681: error: syntax error before "my_path"
/usr/local/include/mysql/my_sys.h:681: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:682: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:683: error: syntax error before "my_load_path"
/usr/local/include/mysql/my_sys.h:683: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:684: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:685: error: syntax error before "pbool"
/usr/local/include/mysql/my_sys.h:686: error: syntax error before "str"
/usr/local/include/mysql/my_sys.h:689: error: syntax error before "strip_sp"
/usr/local/include/mysql/my_sys.h:689: error: syntax error before "str"
/usr/local/include/mysql/my_sys.h:689: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:690: error: syntax error before "to"
/usr/local/include/mysql/my_sys.h:691: error: syntax error before "my_string"
/usr/local/include/mysql/my_sys.h:692: error: syntax error before "File"
/usr/local/include/mysql/my_sys.h:695: error: syntax error before "byte"
/usr/local/include/mysql/my_sys.h:697: error: syntax error before "my_off_t"
/usr/local/include/mysql/my_sys.h:701: error: syntax error before "sigtstp_handler"
/usr/local/include/mysql/my_sys.h:701: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:704: error: syntax error before "my_set_alarm_variable"
/usr/local/include/mysql/my_sys.h:704: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:705: error: syntax error before "size_s"
/usr/local/include/mysql/my_sys.h:706: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:708: error: syntax error before "qsort2"
/usr/local/include/mysql/my_sys.h:709: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:711: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:712: error: syntax error before "my_get_ptr"
/usr/local/include/mysql/my_sys.h:712: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:712: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:713: error: syntax error before "File"
/usr/local/include/mysql/my_sys.h:717: error: syntax error before "my_off_t"
/usr/local/include/mysql/my_sys.h:720: error: syntax error before "byte"
/usr/local/include/mysql/my_sys.h:727: error: syntax error before "byte"
/usr/local/include/mysql/my_sys.h:728: error: syntax error before "byte"
/usr/local/include/mysql/my_sys.h:730: error: syntax error before "byte"
/usr/local/include/mysql/my_sys.h:731: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:732: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:733: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:735: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:743: error: syntax error before "my_off_t"
/usr/local/include/mysql/my_sys.h:745: error: syntax error before "my_b_filelength"
/usr/local/include/mysql/my_sys.h:745: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:750: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:753: error: syntax error before "create_temp_file"
/usr/local/include/mysql/my_sys.h:754: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:754: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:761: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:761: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:762: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:762: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:779: error: syntax error before "ulong"
/usr/local/include/mysql/my_sys.h:795: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:816: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:817: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:818: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:818: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:818: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:819: error: syntax error before "my_checksum"
/usr/local/include/mysql/my_sys.h:819: error: syntax error before "crc"
/usr/local/include/mysql/my_sys.h:819: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:820: error: syntax error before "value"
/usr/local/include/mysql/my_sys.h:821: error: syntax error before "v"
/usr/local/include/mysql/my_sys.h:823: error: syntax error before "m_seconds"
/usr/local/include/mysql/my_sys.h:824: error: syntax error before "crc32"
/usr/local/include/mysql/my_sys.h:824: error: syntax error before "crc"
/usr/local/include/mysql/my_sys.h:824: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:828: error: syntax error before "my_getsystime"
/usr/local/include/mysql/my_sys.h:828: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:829: error: syntax error before '*' token
/usr/local/include/mysql/my_sys.h:861: error: syntax error before "my_off_t"
/usr/local/include/mysql/my_sys.h:872: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:873: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:875: error: syntax error before "myf"
/usr/local/include/mysql/my_sys.h:879: error: syntax error before "flags"
/usr/local/include/mysql/my_sys.h:881: error: syntax error before "escape_string_for_mysql"
/usr/local/include/mysql/my_sys.h:882: error: syntax error before "ulong"
/usr/local/include/mysql/my_sys.h:883: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:889: error: syntax error before "escape_quotes_for_mysql"
/usr/local/include/mysql/my_sys.h:890: error: syntax error before "ulong"
/usr/local/include/mysql/my_sys.h:891: warning: data definition has no type or storage class
/usr/local/include/mysql/my_sys.h:893: error: syntax error before "length"
/usr/local/include/mysql/my_sys.h:894: error: syntax error before "length"
/usr/local/include/mysql/my_sys.h:895: error: syntax error before "length"
In file included from /usr/local/include/mysql/my_sys.h:917,
                 from show_argv.c:3:
/usr/local/include/mysql/raid.h:25: error: syntax error before "C_MODE_START"
/usr/local/include/mysql/raid.h:27: error: syntax error before "extern"
show_argv.c:5: error: syntax error before "char"
show_argv.c: In function `main':
show_argv.c:18: warning: passing arg 2 of `load_defaults' from incompatible pointer type

论坛徽章:
0
4 [报告]
发表于 2007-03-12 22:45 |只看该作者
我是这样编译的
gcc -c -I/usr/local/include/mysql  show_argv.h

是不是不是这样的阿
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP