PDA

View Full Version : c++ macro


ub3r_n00b
06-05-08, 02:08 PM
Hey guys, I am getting a segmentation fault using this macro (this is in C++):



// A parametric macro to allow the use of dynamic multi-dimensional arrays
#define arr(arr,x,y,z,dim) *(arr + (z + dim[2]*(y + dim[1]*(x))))



I am trying to convert this to a function



double arr(double* arr, int x, int y, int z, double* dim)
{
return *(arr + (z + dim[2]*(y + dim[1]*(x))));
}




Would this do the same thing?

ub3r_n00b
07-10-08, 07:08 PM
So it works, issue was with something else.

I hate converting c code that works on Windows to work in Linux Land.