Alright I was compiling my Prizm emulator when I came upon an error. As a global variable I had defined a bit field of 1 byte that is split into two 4 bit variables. I then used a #define to rewrite the bit field so that I would not have to label the the struct name. Here is an eample of the error I got.
unsigned int n = half_byteone;
spectrum.cpp(291: Error: '(' expected following simple type name
struct middle_byte //creates a bit feld for reading the middle byte of an instruction
{
unsigned char half_byteone:4;
unsigned char half_bytetwo:4;
};
unsigned char low_byte; //creates low byte of instruction
#define half_byteone middle_byte.half_byteone
#define half_bytetwo middle_byte.half_bytetwo
blah...
void ADD() //ADD Rm,Rn
{
unsigned int n = half_byteone; //291
unsigned int m = half_bytetwo;
R[n] += R[m];
PC += 2;
return;
}
blah...
half_byteone = (instruction & 0x0F00) / 0x100; // inside the function that calls ADD()
half_bytetwo = (instruction & 0x00F0) / 0x10;
This error appears every time I reference the bit field not just this one example. When I googled this error I found that fixing it involved some sort of weird work with templates (which I have never used before
) Some help on getting this to work would be greatly appreciated.