Random() function
Posted: Tue Sep 20, 2011 9:50 pm
I am trying to use the random() function.
"R = random()" compiles OK to C but then when compiling to assembler gives:
"
.......................................
Nokia LCD Plot 2.c(874:10): error: unknown identifier 'rand'
Nokia LCD Plot 2.c(874:10): error: failed to generate expression
Nokia LCD Plot 2.c(874:10): error: invalid operand 'rand()'
Nokia LCD Plot 2.c(874:8): error: failed to generate expression
Nokia LCD Plot 2.c success
failure
"
R is defined as int, chip 16F887, and removing the above line removes the problem.
There is nothing special in the code otherwise. Sorry I cannot see anything in the help file and adding a value e.g. random(1) does not seem allowed? Advice please.
Thanks
ps saw
If using random() function:
#include <rand.h> should be placed in Supplementary code window. ('View' 'Project Options' & click on 'Use Supplementary code')
If this is the answer then is there a fix in v4.5?
"R = random()" compiles OK to C but then when compiling to assembler gives:
"
.......................................
Nokia LCD Plot 2.c(874:10): error: unknown identifier 'rand'
Nokia LCD Plot 2.c(874:10): error: failed to generate expression
Nokia LCD Plot 2.c(874:10): error: invalid operand 'rand()'
Nokia LCD Plot 2.c(874:8): error: failed to generate expression
Nokia LCD Plot 2.c success
failure
"
R is defined as int, chip 16F887, and removing the above line removes the problem.
There is nothing special in the code otherwise. Sorry I cannot see anything in the help file and adding a value e.g. random(1) does not seem allowed? Advice please.
Thanks
ps saw
If using random() function:
#include <rand.h> should be placed in Supplementary code window. ('View' 'Project Options' & click on 'Use Supplementary code')
If this is the answer then is there a fix in v4.5?