Array of func pointers

Hi,
I need to get a large array of function pointers that have a type defined:
[code]
typedef int (*Cxxx_OPCODE)(struct _xxx* cpu, unsigned char opcode, unsigned char* cycle);

Cxxx_OPCODE opcodes[256];
[/code];

The compiler does not see any problem with it. But when I put the array into a structure:
[code]

typedef struct _xxx{
...
struct _Cxxx_MEMORY* mem;
Cxxx_OPCODE opcodes[256];
Cxxx_TIMING timing[256];
} xxx;
[/code]
I get an error: xxx.h:59: parse error before "Cxxx_TIMING"
When I replace "Cxxx_OPCODE opcodes[256];" with "Cxxx_OPCODE** opcodes;"
it works fine.


Can anybody know what can be wrong?

Thanks.

Comments

  • : Can anybody know what can be wrong?


    Hmmm... maybe you're compiler sucks? ;)

    I don't know. Nothing wrong with that code.

  • :
    : Hmmm... maybe you're compiler sucks? ;)
    :


    yup -- your compiler sucks worse than mine. That compiles ok with VC++ 6.0
    [code]
    typedef int (*Cxxx_OPCODE)(struct _xxx* cpu, unsigned char opcode, unsigned char* cycle);

    Cxxx_OPCODE opcodes[256];

    // this was necessary just to define an object of type Cxxx_TIMING.
    typedef int Cxxx_TIMING;

    typedef struct _xxx{
    struct _Cxxx_MEMORY* mem;
    Cxxx_OPCODE opcodes[256];
    Cxxx_TIMING timing[256];
    } xxx;

    int main()
    {

    return 0;
    }
    [/code]
  • : Hi,
    : I need to get a large array of function pointers that have a type defined:
    : [code]
    : typedef int (*Cxxx_OPCODE)(struct _xxx* cpu, unsigned char opcode, unsigned char* cycle);
    :
    : Cxxx_OPCODE opcodes[256];
    : [/code];
    :
    : The compiler does not see any problem with it. But when I put the array into a structure:
    : [code]
    :
    : typedef struct _xxx{
    : ...
    : struct _Cxxx_MEMORY* mem;
    : Cxxx_OPCODE opcodes[256];
    : Cxxx_TIMING timing[256];
    : } xxx;
    : [/code]
    : I get an error: xxx.h:59: parse error before "Cxxx_TIMING"
    : When I replace "Cxxx_OPCODE opcodes[256];" with "Cxxx_OPCODE** opcodes;"
    : it works fine.
    :
    :
    : Can anybody know what can be wrong?
    :
    : Thanks.
    Just curious, what kind of cpu are you trying to emulate?
  • :
    : :
    : : Hmmm... maybe you're compiler sucks? ;)
    : :
    :
    :
    : yup -- your compiler sucks worse than mine. That compiles ok with VC++ 6.0
    : [code]
    : typedef int (*Cxxx_OPCODE)(struct _xxx* cpu, unsigned char opcode, unsigned char* cycle);
    :
    : Cxxx_OPCODE opcodes[256];
    :
    : // this was necessary just to define an object of type Cxxx_TIMING.
    : typedef int Cxxx_TIMING;
    :
    : typedef struct _xxx{
    : struct _Cxxx_MEMORY* mem;
    : Cxxx_OPCODE opcodes[256];
    : Cxxx_TIMING timing[256];
    : } xxx;
    :
    : int main()
    : {
    :
    : return 0;
    : }
    : [/code]
    :

    That realy sucks, I use GCC mingw, so I think it's realy bad.
    Maybe I have an error that in my code that goes bad only on some contexts.

    I will rewrite the code. I hope it helps.
  • : : Hi,
    : : I need to get a large array of function pointers that have a type defined:
    : : [code]
    : : typedef int (*Cxxx_OPCODE)(struct _xxx* cpu, unsigned char opcode, unsigned char* cycle);
    : :
    : : Cxxx_OPCODE opcodes[256];
    : : [/code];
    : :
    : : The compiler does not see any problem with it. But when I put the array into a structure:
    : : [code]
    : :
    : : typedef struct _xxx{
    : : ...
    : : struct _Cxxx_MEMORY* mem;
    : : Cxxx_OPCODE opcodes[256];
    : : Cxxx_TIMING timing[256];
    : : } xxx;
    : : [/code]
    : : I get an error: xxx.h:59: parse error before "Cxxx_TIMING"
    : : When I replace "Cxxx_OPCODE opcodes[256];" with "Cxxx_OPCODE** opcodes;"
    : : it works fine.
    : :
    : :
    : : Can anybody know what can be wrong?
    : :
    : : Thanks.
    : Just curious, what kind of cpu are you trying to emulate?
    :

    I'm making a big emulator that can handle some of my strange electronic ideas (like emulating a circuit with 2x 6502 and for example a Z80 + a lot of strange memory mapped devices).

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories