Link to two-dimensional matrix

I want to implement a function with OpenGL to map a cylinder in C ++. The signature of my function is this:

#define POINTS_NUM  15
#define DEMESION    3

void drawCylinder( int slices, int segments, GLfloat (&vertices)[ POINTS_NUM ][ DEMESION ] );

I want to use a reference to a two-dimensional array to limit user input, but some strange behavior is happening. When I implement the function declared above, a linker error occurs:

Error 1 error LNK2005: "float (* vase) [3]" (? Vase @@ 3PAY02MA) already defined in shape.obj vase.obj VaseAndAnimation

It is vasedefined here as:

GLfloat vase[ POINTS_NUM ][ DEMESION ];

At first I thought that something was wrong in the last dimension. So I missed it in my second test. This temporary declaration of my function is as follows:

void drawCylinder( int slices, int segments, GLfloat (&vertices)[ POINTS_NUM ][] );

Now a compile-time error occurs when called as (the vasedefinition does not change):

drawCylinder( 10, 10, vase );

Compilation Error:

1 C2087: "" : d:\visual studio 2008\projects\project1\ \vaseandanimation\shapes.h 25 VaseAndAnimation

2 C2664: 'drawCylinder': 3 'GLfloat [14] [3]' 'GLfloat (&) [14] [1]' d:\Visual Studio 2008\Projects\Project1\ \VaseAndAnimation\vase.cpp 64 VaseAndAnimation

3 C2087: "" : d:\visual studio 2008\projects\project1\ \vaseandanimation\shapes.h 25 VaseAndAnimation

4 C2087: "" : d:\Visual Studio 2008\Projects\Project1\ \VaseAndAnimation\shapes.cpp 12 VaseAndAnimation

, vertices , vase float (* vase)[3]?

IDE - Visual Studio 2008. GCC; ?

, - , .

+5
2

. , vase .

+2

, , vase . .

, , (, ). , , .

. , , . , .cpp ( ..), , , , - .

, :

// extern specifies that the definition is elsewhere.
extern int myGlobalVariable;

.

int myGlobalVariable;
+1

All Articles