1833726 Members
2491 Online
110063 Solutions
New Discussion

Re: Ansi c compiler

 
L. Younes
Occasional Advisor

Ansi c compiler

Hi everyone,
does the Ansi C compiler 11.11.02 or the HP-UX 11.00 default shell have a limitation on the number of command line arguments passed ?

I have to compile with a lot of arguments (lots of -I for directory includes) and when I launch the cc command it loops infinitely. When I eliminate only one argument of the ~150 it actually compiles !

Any Ideas ?

Thanks

6 REPLIES 6
Victor BERRIDGE
Honored Contributor

Re: Ansi c compiler

Hi,
You can bipass the shell limitation by using xargs!

All the best
Victor
L. Younes
Occasional Advisor

Re: Ansi c compiler

Thank You for the reply.
But I saw under linux a kernel option that can be increased to alloacte more memory for command line arguments, this requires of course recompiling the kernel.

Is there something similar I can do in sam ?

Thanks
Adam J Markiewicz
Trusted Contributor

Re: Ansi c compiler

In a meanwhile I've found this, which may be of any help for you:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xf5963a1c04ffd61190050090279cd0f9,00.html
Look at the second answer of S.K. Chan

Good luck

Adam
I do everything perfectly, except from my mistakes
Jean-Louis Phelix
Honored Contributor

Re: Ansi c compiler

hi,

In 10.20 this limit was quite small and we needed a kernel parameter to increase it. Since 11.00 there is no increasable limit : it's fixed (and high !!!) in /usr/include/limits.h, (#define ARG_MAX).

# define ARG_MAX 2048000 /* maximum length of arguments for the exec function in bytes, including environment data */

You can get this value using :

# getconf ARG_MAX
2048000

I think your limitation is rather in the compiler.

Regards.
It works for me (© Bill McNAMARA ...)

Re: Ansi c compiler

The maximum number of command line arguments is the kind of thing that varies from system to system, so for portable code you should not rely on having an enormous value.

If you think you need a large value, I suggest reconsidering the design of your program. For example, consider GNU tar. To create a tar archive holding particular files, you place each file as a command-line argument. But tar is often used for backing up large directory trees, meaning potentially many (in fact, an unlimited number of) command-line arguments. Therefore GNU tar has an option for reading a list of filenames from a file. As another example, consider the recursive (-R) option of chmod.
Mike Stroyan
Honored Contributor

Re: Ansi c compiler

Given the huge limit on arguments in 11.00, it seems likely your build is hitting some other problem than total argument length.
However, there is an option to move command arguments into a file instead of the command line. You can use "cc +opts myfile" to ask cc to read options from "myfile" just as if they were on the command line.
There is a similar "-c myfile" option for ld.