473,395 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Maximum number of arguments in a function call

Hi,

Can someone tell me if the language imposes any restrictions on the
maximum number of arguments that can be passed via a function call?

Thanks,
Ashok

Nov 14 '05 #1
9 12986
as***********@gmail.com wrote:

Hi,

Can someone tell me if the language imposes any restrictions on the
maximum number of arguments that can be passed via a function call?


C90 requires implementations to support at least 31 function parameters.
Therefore, portable code should not use more than that number. It is
possible that C99 is more generous to programmers, but I have not
checked this.
Nov 14 '05 #2
On Tue, 01 Mar 2005 10:47:08 +0000, infobahn wrote:
as***********@gmail.com wrote:

Hi,

Can someone tell me if the language imposes any restrictions on the
maximum number of arguments that can be passed via a function call?


C90 requires implementations to support at least 31 function parameters.
Therefore, portable code should not use more than that number. It is
possible that C99 is more generous to programmers, but I have not
checked this.


It is 127 in C99.

Lawrence

Nov 14 '05 #3
In article <pa****************************@netactive.co.uk> ,
lk****@netactive.co.uk says...
On Tue, 01 Mar 2005 10:47:08 +0000, infobahn wrote:
as***********@gmail.com wrote:

Hi,

Can someone tell me if the language imposes any restrictions on the
maximum number of arguments that can be passed via a function call?


C90 requires implementations to support at least 31 function parameters.
Therefore, portable code should not use more than that number. It is
possible that C99 is more generous to programmers, but I have not
checked this.


It is 127 in C99.


IOW they are LESS generous to programmers. Who wants to work on a
function call with even 31 parameters, much less 127?

--
Randy Howard (2reply remove FOOBAR)
"Making it hard to do stupid things often makes it hard
to do smart ones too." -- Andrew Koenig
Nov 14 '05 #4

"Randy Howard" <ra*********@FOOverizonBAR.net> wrote in message
news:MP************************@news.verizon.net.. .
It is 127 in C99.


IOW they are LESS generous to programmers. Who wants to work on a
function call with even 31 parameters, much less 127?


Generated code perhaps?
Nov 14 '05 #5
as***********@gmail.com wrote:

Hi,

Can someone tell me if the language imposes any restrictions on the
maximum number of arguments that can be passed via a function call?

Thanks,
Ashok


IMHO passing that many arguments to a function is an invitation to disaster.
My most serious and hard-to-locate bugs, in programs I wrote in the 1960's-80's
(until I learned not to) came from getting arguments out of order, etc.

Admittedly, with stronger type checking it is less likely to go un-noticed,
but one can still have out of order args of the same type without triggering
any warnings. Better to use arrays, structs, or similar abstractions when
a function needs lots of inputs.
--
Julian V. Noble
Professor Emeritus of Physics
jv*@lessspamformother.virginia.edu
^^^^^^^^^^^^^^^^^^
http://galileo.phys.virginia.edu/~jvn/

"As democracy is perfected, the office of president represents, more and
more closely, the inner soul of the people. On some great and glorious
day the plain folks of the land will reach their heart's desire at last
and the White House will be adorned by a downright moron."

--- H. L. Mencken (1880 - 1956)
Nov 14 '05 #6
Serve Lau wrote:
"Randy Howard" <ra*********@FOOverizonBAR.net> wrote in message
news:MP************************@news.verizon.net.. .
It is 127 in C99.


IOW they are LESS generous to programmers. Who wants to work on a
function call with even 31 parameters, much less 127?


Generated code perhaps?


You sometimes need to run through generated code with a debugger, so I
would hope not.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #7
Actually, this question occured to me when I trying to find if there
could be a potential stack overflow kind of situation even if there is
no recursion in play (with no terminating condition of course).

Thanks,
Ashok

Nov 14 '05 #8
as***********@gmail.com wrote:
Actually, this question occured to me when I trying to find if there
could be a potential stack overflow kind of situation even if there is
no recursion in play (with no terminating condition of course).

Thanks,
Ashok

The standard defines that at least 127 argumnts must be supported in a
function call, at translation time.

This doesn't imply that 127 arguments should be supported at run-time
but it could give a guideline.

Of course if you have:

typedef struct t {
char b[1024*1024*10]; // 10mb array.
} T;

T t1 , t2;
....
myfunction(t1,t2);
....

many systems will crash, even if you have passed only 2 arguments!

Nov 14 '05 #9
You can have a stack overflow with no arguments in the function call. Due
to the amount of previously stacked information before the call.

You'll want to limit the # of items you pass, for speed and efficiency.

for example instead of :
typedef struct t {
char b[1024*1024*10]; // 10mb array.
} T;

T t1 , t2;
...
myfunction(t1,t2);
...
try
myfunction ( &t1, &t2 );

as long as you tell myfunction that t1 is a pointer to that type of struct,
then the compiler works out the proper offsets for each member. You will,
however, need to access the members using "->" instead of ".".

t1->b
"jacob navia" <ja***@jacob.remcomp.fr> wrote in message
news:42**********************@news.wanadoo.fr... as***********@gmail.com wrote:
Actually, this question occured to me when I trying to find if there
could be a potential stack overflow kind of situation even if there is
no recursion in play (with no terminating condition of course).

Thanks,
Ashok

The standard defines that at least 127 argumnts must be supported in a
function call, at translation time.

This doesn't imply that 127 arguments should be supported at run-time but
it could give a guideline.

Of course if you have:

typedef struct t {
char b[1024*1024*10]; // 10mb array.
} T;

T t1 , t2;
...
myfunction(t1,t2);
...

many systems will crash, even if you have passed only 2 arguments!

Nov 14 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steven D'Aprano | last post by:
I'm trying to keep an open mind, but I am perplexed about something in Python that strikes me as a poor design. py> def func(a,b): py> print a,b py> func(1) Traceback (most recent call...
10
by: KemperR | last post by:
Dear All, may be some of you can help me with an XSLT example how to solve the following challange. For the XML below I want to find out the maximum hierarchy level for a specific element in my...
3
by: Vince | last post by:
Hi, I'd like to know how to call a DLL function, when the number of argument can be variant. Thanks, Vince
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
11
by: Leroy | last post by:
Hello, I have a question regarding the maximum number of parameters that can be passed to a procedure. In VB 6 the max was 60. What is the max for Dot Net? please and thanks.
12
by: dima | last post by:
Hello All! Does anybody know anything about type-safe implementation of functions with varying number of arguments? I know one old solution - elipsis (stdarg,h). But it is NOT type-safe! ...
18
by: John Friedland | last post by:
My problem: I need to call (from C code) an arbitrary C library function, but I don't know until runtime what the function name is, how many parameters are required, and what the parameters are. I...
2
by: Alan | last post by:
I have a couple of questions about using a variable number of arguments in a function call (...). The context is that I have some mathematical functions I created. I currently pass them a pair of...
0
by: James Mills | last post by:
On Fri, Oct 31, 2008 at 8:49 AM, mark floyd <emfloyd2@gmail.comwrote: Mark, this is correct behavior. You have 3 positional arguments in the function definition. You _must_ aupply _all_ 3 of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.