{"record":{"id":"f82512c7f138b789","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-funct-f82512","errorCode":null,"errorMessage":"[\" cimg_appname \"_math_parser] CImg<%s>::%s: Function '%s()': Number of specified arguments (%u) does not match macro declaration (defined for %u argument%s), in expression '%s'.","messagePattern":"\\[\" cimg_appname \"_math_parser\\] CImg<(.+?)>::(.+?): Function '(.+?)\\(\\)': Number of specified arguments \\(%u\\) does not match macro declaration \\(defined for %u argument(.+?)\\), in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":24472,"sourceCode":"            if (arg3) { // Macro name matched but number of arguments does not\n              CImg<uintT> sig_nargs(arg3);\n              arg1 = 0;\n              cimglist_for(macro_def,l) if (!std::strcmp(macro_def[l],variable_name))\n                sig_nargs[arg1++] = (unsigned int)macro_def[l].back();\n              _cimg_mp_strerr;\n              cimg::strellipsize(variable_name,64);\n              if (sig_nargs._width>1) {\n                sig_nargs.sort();\n                arg1 = sig_nargs.back();\n                --sig_nargs._width;\n                throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                            \"CImg<%s>::%s: Function '%s()': Number of specified arguments (%u) \"\n                                            \"does not match macro declaration (defined for %s or %u arguments), \"\n                                            \"in expression '%s'.\",\n                                            pixel_type(),_cimg_mp_calling_function,variable_name._data,\n                                            p1,sig_nargs.value_string()._data,arg1,s0);\n              } else {\n                throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                            \"CImg<%s>::%s: Function '%s()': Number of specified arguments (%u) \"\n                                            \"does not match macro declaration (defined for %u argument%s), \"\n                                            \"in expression '%s'.\",\n                                            pixel_type(),_cimg_mp_calling_function,variable_name._data,\n                                            p1,*sig_nargs,*sig_nargs!=1?\"s\":\"\",s0);\n              }\n            }\n          }\n        } // if (se1==')')\n\n        // Char / string initializer.\n        if (*se1=='\\'' &&\n            ((se1>ss && *ss=='\\'') ||\n            (se1>ss1 && *ss=='_' && *ss1=='\\''))) {\n          if (*ss=='_') { _cimg_mp_op(\"Char initializer\"); s1 = ss2; }\n          else { _cimg_mp_op(\"String initializer\"); s1 = ss1; }\n          arg1 = (unsigned int)(se1 - s1); // Original string length\n          if (arg1) {","sourceCodeStart":24454,"sourceCodeEnd":24490,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L24454-L24490","documentation":"Same macro-arity check in CImg's math parser as the sibling error, but for the simple case: the macro is declared for exactly one fixed argument count, and the expression calls it with a different number of arguments. The parser reports the expected count and adds a plural 's' when the expected count is not 1.","triggerScenarios":"Evaluating a math expression that calls a macro defined for a single arity (sig_nargs width == 1) with the wrong number of arguments, e.g. foo(1,2) when foo is declared for 3 arguments.","commonSituations":"Typos in fill() expressions; calling built-in or user macros with extra/fewer comma-separated values; expressions ported between CImg versions where a macro's arity changed.","solutions":["Read the declared argument count (%u) from the message and adjust the call to pass exactly that many arguments.","Review the macro definition in the expression or CImg source for its signature.","Remove surplus arguments or supply missing ones, separated by commas.","If the macro should accept multiple arities, redefine it with a multi-signature declaration.","Validate generated expressions with a unit test calling each macro once before production use."],"exampleFix":"// before\nimg.fill(mymacro(x, y)); // mymacro declared for 1 argument\n// after\nimg.fill(mymacro(x));    // exactly the declared 1 argument","handlingStrategy":"validation","validationCode":"if (callArgCount != macroArity) throw new IllegalArgumentException(\"mymacro expects \" + macroArity + \" argument(s), got \" + callArgCount);","typeGuard":null,"tryCatchPattern":"try {\n    img.fill(expression);\n} catch (CImgInstantiationException e) {\n    if (e.getMessage().contains(\"does not match macro declaration\")) {\n        // parse expected count from message and correct the expression\n    }\n    throw e;\n}","preventionTips":["Count comma-separated arguments carefully in fill() expressions.","Keep macros single-arity unless dual signatures are truly needed.","Run expression smoke tests in CI for every CImg version bump."],"tags":["cimg","math-parser","macro","argument-count"],"backgroundTag":"missing-required-argument","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}