Jump to content

Okay I'm getting pretty annoyed at this bug, can anyone see what the problem is?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
So, I'm at the moment working on an emulator for the Nintendo Entertainment System, aka the Famicom. This entails writing a simulation of the MOS 6502 processor. However, a error has come up on a very simple function declaration, and I'm flummoxed as to the reason.
When taken alone, the declaration:

//#define PREPROCESSOR_TYPES
#ifdef PREPROCESSOR_TYPES
#define byte unsigned char
#define word unsigned short
#else
typedef unsigned char byte;
typedef unsigned short word;
#endif
word rdwd6502(word addr);

--returns no errors. but, when in its actual context in the program (files attached), it returns the following compiler error:

6502.c:3: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rdwd6502’
6502.c:43: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rdwd6502’

So, can anyone explain this phantom to me, or is it something very simple that I've missed?
EDIT: SOLVED.

Attached Files


Edited by Aereshaa, 26 August 2009 - 01:48 PM.

Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What happens with this code:
typedef unsigned char byte;
typedef unsigned short word;
word rdwd6502(word addr);
or this:
unsigned short rdwd6502(unsigned short addr);

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
Both return no errors when on their own, but the first one returns an error when in context, whereas the second one doesn't, even though they should be equivalent. Even when word is defined by a preprocessor macro, it still returns an error unless I specify unsigned short.
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
what if you explicitly specify int?
"unsigned short int"?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
dcs

dcs

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 775 posts
Did you muff the header guard?
#ifdef PROCESSOR_6502
Usually they're written:
#if[COLOR="Red"]n[/COLOR]def PROCESSOR_6502


#6
Aereshaa

Aereshaa

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 790 posts
Okay, dcs, that somehow solved the phantom, and revealed bugs and warnings that it was obscuring. Although I cannot imagine how it was done, thank you.
Watches: Nanoha, Haruhi, AzuDai. Listens to: E-Type, Dj Melodie, Nightcore.
"When people are wrong they need to be corrected. And then when they can't accept it, an argument ensues." - MeTh0Dz