{"record":{"id":"c7608b070edf26de","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-multi","errorCode":null,"errorMessage":"[cimg_appname_math_parser] CImg<%s>::%s: %s: Multiple arguments not allowed when first one is variadic, in macro definition '%s()', in expression '%s'.","messagePattern":"\\[cimg_appname_math_parser\\] CImg<(.+?)>::(.+?): (.+?): Multiple arguments not allowed when first one is variadic, in macro definition '(.+?)\\(\\)', in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":18578,"sourceCode":"            // Assign user-defined macro.\n            if (l_variable_name>2 && *ve1==')' && *ss!='(') {\n              s0 = ve1; while (s0>ss && *s0!='(') --s0;\n              if (cimg::is_varname(ss,s0 - ss) && std::strncmp(variable_name,\"debug(\",6) &&\n                  std::strncmp(variable_name,\"print(\",6)) { // Valid macro name\n                s0 = variable_name._data + (s0 - ss);\n                *s0 = 0;\n                s1 = variable_name._data + l_variable_name - 1; // Pointer to closing parenthesis\n                CImg<charT>(variable_name._data,(unsigned int)(s0 - variable_name._data + 1)).move_to(macro_def,0);\n                ++s; while (*s && cimg::is_blank(*s)) ++s;\n                CImg<charT>(s,(unsigned int)(se - s + 1)).move_to(macro_body,0);\n\n                bool is_variadic = false;\n                p1 = 1; // Index of current parsed argument\n                for (s = s0 + 1; s<=s1; ++p1, s = ns + 1) { // Parse function arguments\n                  if (is_variadic && p1>1) {\n                    _cimg_mp_strerr;\n                    cimg::strellipsize(variable_name,64);\n                    throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                                \"CImg<%s>::%s: %s: Multiple arguments not allowed when first one is \"\n                                                \"variadic, in macro definition '%s()', in expression '%s'.\",\n                                                pixel_type(),_cimg_mp_calling_function,s_op,\n                                                variable_name._data,s0);\n                  }\n                  if (p1>24) {\n                    _cimg_mp_strerr;\n                    cimg::strellipsize(variable_name,64);\n                    throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                                \"CImg<%s>::%s: %s: Too much specified arguments (>24), in macro \"\n                                                \"definition '%s()', in expression '%s'.\",\n                                                pixel_type(),_cimg_mp_calling_function,s_op,\n                                                variable_name._data,s0);\n                  }\n                  while (*s && cimg::is_blank(*s)) ++s;\n                  if (*s==')' && p1==1) break; // Function has no arguments\n                  s2 = s; // Start of the argument name\n                  is_sth = true; // is_valid_argument_name?","sourceCodeStart":18560,"sourceCodeEnd":18596,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L18560-L18596","documentation":"When defining a macro whose first parameter is variadic (declared so it can absorb a variable number of arguments), no additional parameters may follow it. The parser throws CImgArgumentException if it finds more than one argument in a macro definition whose first argument is variadic.","triggerScenarios":"Defining a macro like mymacro(...,x) or (... , a, b) — i.e. a variadic first parameter plus extra named parameters; e.g. \"m(a,...) : ...\" written so that after the variadic marker further arguments are parsed.","commonSituations":"Authors assuming C-style varargs semantics (variadic must be last, but CImg requires it be the only/first with no extras); converting functions with many args into variadic macros incorrectly.","solutions":["Remove the extra arguments after the variadic parameter — keep only the single variadic argument.","If you need fixed parameters, declare them explicitly instead of making the first one variadic.","Split the macro into two versions: one with fixed args and one variadic.","Check macro definitions for stray commas producing phantom extra arguments."],"exampleFix":"// before\n\"myjoin(...,sep) : ...\" // variadic first arg plus extra 'sep' -> throws\n// after\n\"myjoin(...) : ...\" // only the variadic argument; embed separator inline","handlingStrategy":"validation","validationCode":"// reject macro definitions mixing a variadic first arg with extra parameters\nif (macro_def_has_variadic_plus_extra_args(def)) return ERR_BAD_MACRO_DEF;\nimg.eval(expr_with_macros);","typeGuard":null,"tryCatchPattern":"try {\n  img.eval(expr);\n} catch (const CImgArgumentException& e) {\n  if (strstr(e.what(), \"variadic\")) {\n    // fix the macro definition: keep only the variadic argument\n  }\n}","preventionTips":["Remember CImg semantics: a variadic first macro parameter must be the only parameter.","Declare fixed parameters explicitly instead of mixing with variadic ones.","Keep macro definitions in reviewed constants/resources, not ad-hoc strings.","Test macro-heavy expressions during development, not just in production."],"tags":["cimg","math-expression","macro","variadic"],"backgroundTag":"invalid-argument-value","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"}