On 29 August 2011 09:14, David Waroquiers <david.waroquiers@xxxxxxxxx> wrote: > Hello, > > I would like to make a macro MY_ALLOCATE(myarray) where myarray will > be something like arr(dim1,dim2,...,dimN). The MY_ALLOCATE should be > replaced by 2 lines : > 1) allocate(myarray) /* with my array being for example > arr(dim1,dim2,...,dimN) */ > 2) call to another function like : foo(arr) /* where arr is myarray > but without the dim1 .... */ > > Example : > ndim = 3; > MY_ALLOCATE(array(ndim,3,12)) > would be changed to : > allocate(array(ndim,3,12)) > call foo(array) > > > I have tried this : > > #define MY_ALLOCATE(myarray(myshape)) allocate(myarray(myshape)) \ > call foo(myarray) > > But it does not work :/ > > I do not want to have something like MY_ALLOCATE(myarray,myshape), the > argument list needs to be exactly like in the allocate call. > > Any ideas ? > > Thanks a lot ! > > David > I feel a little confused with your description you want a macro to be like: void allocate (yourtype dim1, ...) { va_list args; va_start (args, dim1) ... } extern void allocate (yourtype, ...); #define my_macro(...) \ allocate (__VA_ARGS__) do_calls (__VA_ARGS__) my_macro (myarrary,myshape,....) This is where i get confused you want your argument to be a call but then get the identifier of the call? I dont really understand. I think thats a big enough hint for you to get started though. --Phil