在自己的程序中调用编译好的库函数时,如果库函数会输出一些提示信息(比如初始化信息、版本信息或者警告信息)而你又不喜欢这些信息,并且你希望保留另外一些函数的标准输出,可以在编程调用时这样做:
通常C语言中实现可变参数函数的方法,要利用<stdarg.h>的库函数,比如
http://c-faq-chn.sourceforge.net/ccfaq/node261.html
看上去比较繁琐。
今天忽然想到可以借助结构体实现这样的功能。首先根据所有可能用到的参数定义一个结构体,比如
struct par_all { int var_i; int var_j; float var_x; float var_y; char *var_c; char *var_d; ... } myparam;
然后定义函数
The following error was reported when I was trying to install the k-correction and photo-z package from http://cosmo.nyu.edu/~mb144/kcorrect/
on a sgi altix 64-bit server with gnu-linux system:
/usr/bin/ld: /opt/kcorrect/bin/k_test_filter: hidden symbol `__modsi3' in /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/libgcc.a(__modsi3.oS) is referenced by DSO
collect2: ld returned 1 exit status
make[1]: *** [/opt/kcorrect/bin/k_test_filter] Error 1
while it passes without problem on my local ubuntu 8.10 system.
http://c-faq-chn.sourceforge.net/
非常实用的C语言编程参考手册,极力推荐。
最新评论
10 周 17 小时 前
38 周 4 小时 前
38 周 1 天 前
39 周 5 天 前
46 周 3 天 前
46 周 6 天 前
47 周 3 天 前
1 年 2 周 前
1 年 2 周 前
1 年 11 周 前