casting - Calling C functions with too many arguments -
i changing function signatures of class of functions in application. these functions being stored in function table, expecting change function table well. have realised in instances, use new function signature. because casted correct function type put function table, no warnings being raised.
when function called, passed parameters not part of function declaration, on end of parameter list.
i can't determine if guaranteed way function parameters passed in c. guess variadic functions sprintf, has case earlier arguments can resolved correctly whatever on end of parameter list?
it evidently works fine across multiple platforms out of curiosity i'd know how , why works.
your functions must using cdecl calling convention (http://en.wikipedia.org/wiki/x86_calling_conventions#cdecl). pushes arguments on stack in reverse order, right left, ensuring last argument can located (top of stack) , used interpret remainder, such printf format string. responsibility of caller clean stack, bit less compact function doing (as in pascal/stdcall convention), ensures variable argument lists can used, , implies trailing arguments can ignored.
Comments
Post a Comment