Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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, 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!

like image 389
Tim Avatar asked Nov 15 '09 04:11

Tim


People also ask

How do you fix too many arguments in a function?

Solution. So to fix the error “You've entered too many arguments for this function” you need to go through the content of the cell, character-by-character, to ensure that there are no syntax errors. In other words, you need to check whether all opened brackets are closed and all commas are properly in place.

What is too few arguments?

Too few arguments means fewer arguments than the number of required parameters for the function. If this situation occurs in a safe call, an error of type program-error must be signaled; and in an unsafe call the situation has undefined consequences.

How many arguments is too many for a function?

Functions with three arguments (triadic function) should be avoided if possible. More than three arguments (polyadic function) are only for very specific cases and then shouldn't be used anyway.

How many number of arguments functions can take?

Series: Functions Functions can define default argument values, functions can be called with keyword arguments, and functions can be written to accept any number of arguments.


1 Answers

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.

like image 68
Jonathan Leffler Avatar answered Oct 23 '22 19:10

Jonathan Leffler