Re: Calling a function with a literal list of strings?
- From: Joakim Hove <joakim.hove@xxxxxxxxx>
- Date: Tue, 31 Jul 2007 09:11:32 -0000
Dear Chris,
thank you *very much* for a thorough and informative answer - I have
learned a lot today.
The thing in front of the brace list *looks* exactly like a cast,
but is not actually a cast. Instead, it is the type-specifier
part of a "compound literal".
The type-specifier of a compound literal - neat!
Because the call to func() is within a block (all function calls
in C are always inside a block -- you cannot call a function
outside the outermost block of some other function), the object
created by such a call has automatic duration. In practice, this
means you get runtime code to create the array. You may get
slightly better performance if you just give in and create an
actual object, which you can then make "static":
I won't give in - I just love the compact calls like:
func (3 , (const char *[]) {"S" , "S2" , "..."});
which I can now use - thanks to your help. The call will be issued in
the initialization part of the code, and performance is irrelevant.
Regards
Joakim Hove
.
- References:
- Calling a function with a literal list of strings?
- From: Joakim Hove
- Re: Calling a function with a literal list of strings?
- From: Chris Torek
- Calling a function with a literal list of strings?
- Prev by Date: Re: circular shift array
- Next by Date: Re: Staic array de allocation
- Previous by thread: Re: Calling a function with a literal list of strings?
- Index(es):