Hello, I am writing a C compiler in Java and I'm getting the following errors in one of my generated C programs:
output.c:6: warning: data definition has no type or storage class
output.c:6: error: conflicting types for ‘M’
output.c:1: note: previous declaration of ‘M’ was here
output.c:6: error: invalid initializer
output.c:7: warning: data definition has no type or storage class
output.c:7: error: conflicting types for ‘M’
output.c:1: note: previous declaration of ‘M’ was here
output.c:7: error: invalid initializer
and my program looks like:
Code:
int M[5000];
#define base M[0]
#define top M[1]
#define jump_reg M[2]
base = 3;
top = 3;
#include <stdio.h>
int max ( int a , int b )
{
if ( a > b ) goto AutoGenLabel1;//auto-if
goto AutoGenLabel0;//auto-if
AutoGenLabel1://auto-if
return a;
AutoGenLabel0://auto-if
;//auto-if
return b;
}
int main ( )
{
int a , b;
scanf ( "%d" , & a );
scanf ( "%d" , & b );
M[base] = max ( a , b );//auto
printf ( "%d\n" , M[base] );
}
What exactly is going on?
Thanks for your fast respone