From: Oystein Thorsen (othorsen_at_mtu_dot_edu)
Date: Sat Jan 02 2010 - 23:39:12 PST
Hi, I was looking at the code for allocating a shared 2D array (posted on this email list early December 09) and tried to put it in a function that returns the pointer to the array, but I get a warning from the compiler that doesn't make much sense to me: (The program seems to work fine if I ignore the error though) $ upcc test.c test.c: In function `allocate2DArray': test.c:26: warning: return from incompatible pointer type $ Here is a simplified version of the code (All in one file): #include <upc_relaxed.h> #include <stdio.h> shared [] int *shared * allocate2DArray(int rows, int columns); int main() { shared [] int *shared * data; data = allocate2DArray(5, 3); return 0; } // Allocate a 2D Array in shared space with a row-wise round-robin distribution. shared [] int *shared * allocate2DArray(int rows, int columns) { shared [] int *shared * array; int r, c; array = (shared [] int *shared *)upc_all_alloc(rows, sizeof(shared [] int *shared)); upc_barrier; for (r = 0; r < rows; ++r) { if (upc_threadof(&array[r]) == MYTHREAD) { array[r] = (shared [] int *shared)upc_alloc(sizeof(shared int) * columns); } } return array; //<===== Warning points to this line } end of code I'm using the Berkeley upcc compiler version 2.10.0 with remote translation. The warning goes away if I move the declaration of allocate2DArray() to where the prototype is (and remove the prototype). Or if I cast array to remove the blocking factor on return: return (shared int *shared *)array; The warning comes back if I do both.... Regards, Oystein