C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28695
Number of posts: 94715

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Array of func pointers Posted by PrzemekG_ on 3 Sept 2004 at 3:34 PM
Hi,
I need to get a large array of function pointers that have a type defined:
typedef int (*Cxxx_OPCODE)(struct _xxx* cpu, unsigned char opcode, unsigned char* cycle);

Cxxx_OPCODE	opcodes[256];
;

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

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

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.
Report
Re: Array of func pointers Posted by Eric Tetz on 3 Sept 2004 at 4:18 PM
: Can anybody know what can be wrong?


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

I don't know. Nothing wrong with that code.
Report
Re: Array of func pointers Posted by stober on 3 Sept 2004 at 4:37 PM

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


yup -- your compiler sucks worse than mine. That compiles ok with VC++ 6.0
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;
}

Report
Re: Array of func pointers Posted by PrzemekG_ on 6 Sept 2004 at 5:12 AM
:
: :
: : Hmmm... maybe you're compiler sucks? ;)
: :
:
:
: yup -- your compiler sucks worse than mine. That compiles ok with VC++ 6.0
:
: 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;
: }
: 

:

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.
Report
Re: Array of func pointers Posted by shaolin007 on 3 Sept 2004 at 6:49 PM
: Hi,
: I need to get a large array of function pointers that have a type defined:
:
: typedef int (*Cxxx_OPCODE)(struct _xxx* cpu, unsigned char opcode, unsigned char* cycle);
: 
: Cxxx_OPCODE	opcodes[256];
: 
;
:
: The compiler does not see any problem with it. But when I put the array into a structure:
:
: 
: typedef struct _xxx{
:    ...
: 	struct _Cxxx_MEMORY* mem;
: 	Cxxx_OPCODE	opcodes[256];
: 	Cxxx_TIMING	timing[256];
: } xxx;
: 

: 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?
Report
Re: Array of func pointers Posted by PrzemekG_ on 6 Sept 2004 at 5:15 AM
: : Hi,
: : I need to get a large array of function pointers that have a type defined:
: :
: : typedef int (*Cxxx_OPCODE)(struct _xxx* cpu, unsigned char opcode, unsigned char* cycle);
: : 
: : Cxxx_OPCODE	opcodes[256];
: : 
;
: :
: : The compiler does not see any problem with it. But when I put the array into a structure:
: :
: : 
: : typedef struct _xxx{
: :    ...
: : 	struct _Cxxx_MEMORY* mem;
: : 	Cxxx_OPCODE	opcodes[256];
: : 	Cxxx_TIMING	timing[256];
: : } xxx;
: : 

: : 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).




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.