开发者

"error: too few arguments to function"

I have a C program called opencv2.0 function :

cvSaveImage( out_img_name, img);  

Compiler gcc reports that

too few arguments to function cvSaveImage

The prototype of cvSaveImage in highgui.h is

CVAPI(int) cvSaveImage( const char* filename, const CvArr* image, 开发者_StackOverflow社区const int* params CV_DEFAULT(0) )

After I change my call to be

cvSaveImage( out_img_name, img, 0);  

The compilation is finally successful. Does it mean default values of arguments for function are only supported in C++ but not C?

Thanks and regards!


Correct - Standard C does not support default arguments, neither in the C89 standard nor in the C99 standard (nor in the C2011 standard). There may be compiler-specific extensions to support it in some compilers, but it is not standard.


C requires a special notation if you want to use a variable number of arguments.

http://www.swig.org/Doc1.3/Varargs.html

You can't define a default variable to be passed in to a plain function. You could set-up a macro that auto-magically passes in a default value and use that as your function entry if you want to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜