paragk <> writes:
> On Jan 28, 12:28Â*pm, Keith Thompson <ks...@mib.org> wrote:
>> paragk <parag.kan...@gmail.com> writes:
[...]
>> > How about:
>>
>> > Â*main()
>> > Â*{
>> > Â* Â*declare_func("abc");
>> > Â* Â*declare_func("pqr");
>> > Â*}
>>
>> > Will this work?
>>
>> I don't believe there's any way to get the proprocessor to convert
>> a string literal to an identifier.
[...]
>> Exactly what problem are you trying to solve?
>
> I have a function which takes a number of parameters. The parameter
> names have a fixed template.
>
> For e.g.
>
> foo( int a, int b, int c)
>
> I need to call foo() multiple times with the following arguments
>
> foo( param_first, param_second, param_third);
> foo( param1_first, param1_second, param1_third);
> foo( test_first, test_second, test_third);
If you only have one function to be called, why are you looking for
a macro that generates a function declaration? Just declare foo,
and you're done (at least with that part).
> ...
>
> Lets assume the parameters are global variables.
Why are they global variables?
> I can have a table which lists all the parameters:
>
> for e.g.
>
> struct {
>
> int first,
> int second,
> int third
> } param_template
>
> and then an array of this struct
>
> [ {param_first, param_second, param_third},
> {param1_first, param1_second, param1_third},
> {test_first, test_second, test_third},
> ...
> ]
If you have a series of objects, each of which is to be passed as the
first (, second, third) argument to foo(), perhaps the whole series
should just be declared as an array. Or maybe you should have an array
of structs, where each struct contains all three parameters.
Just declare your array(s) and loop over it. No need for any macros.
[snip]
Oh, and please snip some of the quoted text when you post a followup.
Just keep whatever is needed for the followup to make sense.
In particular, please don't quote signatures (the lines following
the "-- " delimiter).
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"