random number generation CW 5.7 MC9S08RE16

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

random number generation CW 5.7 MC9S08RE16

2,638 次查看
stevec
Contributor III
I wish to generate a random number using the rand() function.as in

number = rand();

but I get a warning "No copydown created for initialised object 'seed'. Initialization data lost.

What am I missing? I don't understand what 'copydown' is.

Steve
标签 (1)
0 项奖励
2 回复数

424 次查看
stevec
Contributor III
I have declared and initialised 'seed' (=10000) and used srand(seed) prior to the rand() call. I still get the same warning.
0 项奖励

424 次查看
CrasyCat
Specialist III
Hello
 
Are you linking the standard startup file (start08.o) to your application or are you using your own startup function?
 
Are you building with -D__ONLY_INIT_SP?
 
seed is a global variable and as such need to be initialized at Startup.
 
In fact in order to get global variables initialized at Startup I would recommend you to link the standard startup function to your application and to use the standard ANSI c startup code (build without 
-D__ONLY_INIT_SP).
 
This should avoid the warning.
 
CrasyCat
0 项奖励