My code:
.h file:
extern const int* g_position;
inline DWORD pos_x(BYTE v) {
if (1 <= v && v <= 3)
return g_position[v][0];
return 0;
}
inline DWORD pos_y(BYTE v) {
if (1 <= v && v <= 3)
return g_position[v][1];
return 0;
}
.cpp file:
const int* g_position = (int*) 0x86b2fdc;
What I am trying to do is address the function which is basically a two-dimensional array:
(DWORD (*)[4][2]) 0x86b2fdc<g_position>
For some reason I am getting the following error(s) while compiling:
In function 'gev::DWORD pos_y(BYTE)':
error: invalid types 'const int[int]' for array subscript
return g_position[v][0];
What is wrong in my code? I am declaring the g_position as an array type so it should work.
g_positionis onlyint *, so you can't dereference twice. Also, what exactly are you trying to do? In general, hard-coding a pointer is a bad idea. In any case theextern const ...declaration ofg_positionneeds to match whatever declares that object at0x86b2fdc