Hello. Actually the whole question is in the subject. The secondary question is: what is the largest number of arguments that can be most effectively passed to a function without overhead actions. Waiting for answers <3

  • Depends on the architecture and calling conventions . For example, in x86-64, 6 first integers are transmitted in registers - avp pm
  • And this is why you need it? Just wondering. Usually in C the issue is solved by passing a pointer to the structure. In C ++, it's even easier with member functions. - Pavel Gridin 7:16 pm
  • The question is formulated meaninglessly. What is "can"? - AnT

2 answers 2

According to the C ++ standard, the function supports declaring up to 256 arguments (this is the minimum that a particular architecture should implement). As a rule, it is undesirable to push a function with a lot of arguments.

Overhead costs will be noticeable if you recursively call this function (stackoverflow occurs faster if the function has more arguments).

    1. It is not clear what is "possible." How many compilers will allow? Or how much is correct? Or how much will pass to pass at runtime?

      How many arguments the compiler will allow you to pass to the function depends on how many parameters are specified in the function declaration. How much is indicated - so much and will allow, no more, no less.

      Exceptions are functions with ... parameters in C and C ++, functions with template parameter pack in C ++, and functions declared without a prototype in C. Any number of arguments can be passed in them (up to implementation constraints, if any).

      However, in the case of functions declared without a prototype in C, passing an incorrect number of arguments will result in undefined behavior.

      How many arguments will be passed at runtime depends, of course, on the physical size of each argument.

    2. It is not clear what is "effective".

      If we are talking about the transfer through the registers of the processor, it depends on the number of registers of the processor and accepted on the platform calling agreements.