Mail Archives: djgpp/2001/01/06/14:36:45
Dennis Cartwright wrote:
> The following code is from the beginning stages of a prog I am
> writing to simulate a "hold em" poker game.
> When I compile with gcc -c PokerA.cpp, I get the following error
> message:
>
> PokerA.cpp In method void Table::firstDeal()':
> Pokeraccpp : 146: Internal compiler error in `find_function_data' at
> function c:542
> Please submit a full bug report
> See http://www.gnu.org/software/gcc/faq.html#bugreport
>
> Before I attempt to submit a bug report, does anyone see an error in my
> code that I might be overlooking, or does anyone see a workaround I might
> put in?
Your code is wrong. But, of course, internal compiler errors
shouldn't occur even for incorrect code.
> #include <stdlib.h>
> #include <time.h>
> #include <iostream>
>
> int NP; // number of players
[snip lots of code]
> class Table {
> private:
> Player p[NP];
Here's the problem. The value of NP isn't known (and NP
isn't even const), so you can't define the structure of
a class in terms of it. One solution would be to make
Table::p a std::vector<Player>, and initialize it to the
correct size in the constructor. Another solution is to
make Table::p a pointer and allocate some memory for it
in the constructor (and delete it in the destructor).
- Raw text -