主要全局变量
2016-12-17 16:16:18 0 举报
全局变量是编程中的一种重要概念,它是指在程序的任何地方都可以访问的变量。全局变量通常在所有函数外部定义,因此它们在整个程序的生命周期内都存在。这使得全局变量成为存储和共享数据的理想选择,尤其是在需要跨多个函数或模块访问数据时。然而,过度使用全局变量可能会导致代码难以理解和维护,因为它们可以在程序的任何地方被修改。因此,开发者在使用全局变量时应谨慎考虑,确保它们确实为程序提供了必要的功能,并且其使用方式不会导致程序的其他部分出现问题。
作者其他创作
大纲/内容
//define.h//global varialbes//#include control.h //#include senser.h//system parameter#define NUM_TOTAL 20;#define DISTANCE1 8;#define DISTANCE2 6;//system recordsglobal int status[20] = {0};global int num_wipe = 0;global int num_hat = 0;//system running status;recording the status of one peried global enum running_status{\tready;\tupload;\talready;\twipe_only;\twipe_detect;\twipe_detect_hat;\tdetect_hat;\that;\tfinish;\tback;\tunload;} peried;//system operating statusglobal enum operating_status{\tusual;\t\t//perform well\tdrop_out;\t\t//optical fiber\thalt;\t\t\t//worker suddun stop system\twipe_error;\t//the material used for wiping finish or break\that_error;\t\t//the hat finish};global bool rail_run = false;
0 条评论
下一页