找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2015|回复: 4
打印 上一主题 下一主题
收起左侧

大家帮看看为什么C语言全局变量会有警告呢

[复制链接]
跳转到指定楼层
楼主
ID:370473 发表于 2020-4-11 23:02 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include "stc8.h"
#include "intrins.h"
#include "lcd_lite.h"
#include  "mhz.h"
#include "3231.h"
#include "h.h"
         


        int count1=0;
        int secondss=0;
        
                        

void main(){
//fountion('s',y,m,d,w,h,mi,s);
int y=20;
int m=4;
int d=11;
int w=6;
int h=21;
int mi=32;
int s=30;
        

init();
        
P14=0;
Time0_Init();
show();



        
        
while(1){
EA = 0;

if(P53==0)
{fountion('s',y,m,d,w,h,mi,s);}



fountion('r',20,3,4,3,12,10,50);
LCDnum2(2,get_time(3));//week

LCDnum2(6,get_time(6));//data
LCDnum2(10,get_time(5));
LCDnum2(14,get_time(4));

LCDnum2(2+0x40,get_time(2));//time
LCDnum2(6+0x40,get_time(1));
LCDnum2(10+0x40,get_time(0));


        
LCDnum4(12+0x40,count1);

if(get_time(0)!=secondss){count1++;if(count1>2400)count1=0;secondss=get_time(0);}

EA = 1;}}



警告如下

Rebuild started: Project: lite
Rebuild target 'Target 1'
assembling STARTUP.A51...
compiling main.c...
compiling 3231.c...
compiling delay.c...
compiling lcd_lite.c...
compiling mhz.c...
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
    SEGMENT: ?C_INITSEG
Program Size: data=78.0 xdata=0 code=2274
creating hex file from "lite"...
"lite" - 0 Error(s), 1 Warning(s).
Build Time Elapsed:  00:00:00



请大家帮帮忙谢谢!

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:235200 发表于 2020-4-12 09:51 | 只看该作者
L16的警告不是涉及全局变量,而是未用到的子函数,不影响程序运行
回复

使用道具 举报

板凳
ID:727347 发表于 2020-4-12 09:52 | 只看该作者
一般全局变量的警告是因为你定义的全局变量没有被包含,比如我在key.c里定义了一个全局变量,那么我在main里如果想要用这个变量就需要在开头加上#include"key.h",并且在key.h里添加上全局变量的定义
回复

使用道具 举报

地板
ID:452950 发表于 2020-4-12 10:02 | 只看该作者
某个函数定义了没有调用到
回复

使用道具 举报

5#
ID:591189 发表于 2020-4-13 10:53 | 只看该作者
这个警告不影响你正常使用,要消除把没用到的子函数注释掉就好了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表