找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

帖子
查看: 2759|回復: 4
打印 上一主題 下一主題
收起左側

大家?guī)涂纯礊槭裁碈語言全局變量會有警告呢

[復制鏈接]
跳轉到指定樓層
樓主
ID:370473 發(fā)表于 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



請大家?guī)蛶兔χx謝!

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發(fā)
ID:235200 發(fā)表于 2020-4-12 09:51 | 只看該作者
L16的警告不是涉及全局變量,而是未用到的子函數(shù),不影響程序運行
回復

使用道具 舉報

板凳
ID:727347 發(fā)表于 2020-4-12 09:52 | 只看該作者
一般全局變量的警告是因為你定義的全局變量沒有被包含,比如我在key.c里定義了一個全局變量,那么我在main里如果想要用這個變量就需要在開頭加上#include"key.h",并且在key.h里添加上全局變量的定義
回復

使用道具 舉報

地板
ID:452950 發(fā)表于 2020-4-12 10:02 | 只看該作者
某個函數(shù)定義了沒有調用到
回復

使用道具 舉報

5#
ID:591189 發(fā)表于 2020-4-13 10:53 | 只看該作者
這個警告不影響你正常使用,要消除把沒用到的子函數(shù)注釋掉就好了
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表