I have a issue that compiles with a void pointer in vs90 but fails to compile with g++.
The first class opens and reads binary files parsing the data.
The second class is meant to interface with the first class indexing them by a pointer array to the class.
Class A
{
}
Class B
{
A *index[64][64];
}
Under Visual Studio I could use a void pointer to represent the index, however in Linux I am unable to do so. The above compiles fine also, all header files have guards. "Class B" includes "Class A" and I can create the actual array like ADT index[x][y], but not the pointers.
Compilation errors:
ISO C++ forbids declaration of 'A' with no type.
expected ';' before '*' token.
Any help resolving this issue or suggestions on a better way to do it would be greatly appreciated.
It will always by a 64 by 64 array of files however some files may be missing in which case they are to be discarded so the empty class doesn't consume resources.
Your class declarations must terminate with a semicolon. (All type declarations must terminate with a semicolon.)
Also, you should not be using a void* to reference the items. This tells the compiler to shut up about all other errors you are likely making.
To do references, either #include the first file's header or use a forward reference.
1 2 3 4
// file A
class A
{
};
1 2 3 4 5 6 7 8 9 10 11
// file B
// If you want to simply include the first file's header then use the next line
#include "fileA.hpp"
// Otherwise, use a forward reference to the class A with the next line
class A;
class B
{
A *index[64][64];
};
BTW, do you realize how much memory you are using for a 64 by 64 array of references? (It's probably around 16384 bytes...) That is a massive amount. Wouldn't a sparse matrix do better?
Also, how could you possibly be using up to 4096 files at once? The OS might not even permit it.
Apparently taking a little break 15 minute break allowed me to notice the A.h including B.h which included A.h but the header guards blocked the redefinition(A got defined after B).
Thanks for the reply, it opens reads the file and then closes it. Its for navmesh generation and takes a insane amount of memory to begin with when the triangles are loaded, win32 oses had no issue loading this data. I will look into a sparse matrix route but memory was not a to much of a concern for me(and im not c++ expert). Thanks for your reply.