NXC: unexpected compiler error
Posted: 13 Jun 2011, 16:42
hi,
I don't know why - but I bet a compiler error with this code:
Any helping hand...?
I don't know why - but I bet a compiler error with this code:
Code: Select all
// srand test
//********************************************
// randomize functions
//********************************************
// global variables and functions to plant a random seed and to randomize
// how to use:
// srand(x) // x = val. for repet. sequences
// myVar = rand_() % 100; // assignes a random number
unsigned long _RAND_SEED_ = 1; // patched by srand()
unsigned long START_SEED = abs(CurrentTick()*BatteryLevel());
unsigned long rand_() // random function
{
_RAND_SEED_ = _RAND_SEED_ * 1103515245 + 12345;
return (_RAND_SEED_ % (RAND_MAX + 1));
}
void srand(int seed) // seeds for a new random series
{
_RAND_SEED_ = seed; // patch
}
task main(){
int irVal;
srand(START_SEED);
irVal=rand_()%100;
printf("randVal=%3d", irVal);
while(1) {
irVal=rand_()%100;
printf("randVal=%3d", irVal);
Wait(500);
}
}
I really have no idea why.# Error: Invalid constant expression
File "c:\Temp\temp.nxc" ; line 17
# u
#----------------------------------------------------------
Any helping hand...?