尽管已经定义了函数主体,但编译器仍对“隐式声明”发出警告

时间:2019-07-15 18:31:32

标签: c implicit

我想为GameBoy磁贴编号创建一个ASCII转换器

我首先将函数放在另一个文件中,所以我尝试将它们移到使用了函数的相同文件中。我不知道接下来要尝试什么,所以我回到了这里。

#include <gb/gb.h>
#include <gb/font.h>
#include "../tiles/WindowMap.c"

#define ASCII_0 0x02
#define ASCII_1 0x03
#define ASCII_2 0x03
#define ASCII_3 0x03
#define ASCII_4 0x03
#define ASCII_5 0x03
#define ASCII_6 0x03
#define ASCII_7 0x03
#define ASCII_8 0x03
#define ASCII_9 0x03
#define ASCII_A 0x03
#define ASCII_B 0x03
#define ASCII_C 0x03
#define ASCII_D 0x03
#define ASCII_E 0x03
#define ASCII_F 0x03
#define ASCII_G 0x03
#define ASCII_H 0x03
#define ASCII_I 0x03
#define ASCII_J 0x03
#define ASCII_K 0x03
#define ASCII_L 0x03
#define ASCII_M 0x03
#define ASCII_N 0x03
#define ASCII_O 0x03
#define ASCII_P 0x03
#define ASCII_Q 0x03
#define ASCII_R 0x03
#define ASCII_S 0x03
#define ASCII_T 0x03
#define ASCII_U 0x03
#define ASCII_V 0x03
#define ASCII_W 0x03
#define ASCII_X 0x03
#define ASCII_Y 0x03
#define ASCII_Z 0x03

unsigned char Char_to_GBSCII(unsigned char character){   
    switch(character){
            case 'A': return ASCII_A;
            case 'B': return ASCII_B;
            case 'C': return ASCII_C;
            case 'D': return ASCII_D;
            case 'E': return ASCII_E;
            case 'F': return ASCII_F;
            case 'G': return ASCII_G;
            case 'H': return ASCII_H;
            case 'I': return ASCII_I;
            case 'J': return ASCII_J;
            case 'K': return ASCII_K;
            case 'L': return ASCII_L;
            case 'M': return ASCII_M;
            case 'N': return ASCII_N;
            case 'O': return ASCII_O;
            case 'P': return ASCII_P;
            case 'Q': return ASCII_Q;
            case 'R': return ASCII_R;
            case 'S': return ASCII_S;
            case 'T': return ASCII_T;
            case 'U': return ASCII_U;
            case 'V': return ASCII_V;
            case 'W': return ASCII_W;
            case 'X': return ASCII_X;
            case 'Y': return ASCII_Y;
            case 'Z': return ASCII_Z;
            case '1': return ASCII_1;
            case '2': return ASCII_2;
            case '3': return ASCII_3;
            case '4': return ASCII_4;
            case '5': return ASCII_5;
            case '6': return ASCII_6;
            case '7': return ASCII_7;
            case '8': return ASCII_8;
            case '9': return ASCII_9;
            case '0': return ASCII_0;
        }
}
unsigned char* String_To_GBSCII(const char* message){
    unsigned char r[20];
    r[0] =  Char_to_GBSCII(message[0]);
    r[1] =  Char_to_GBSCII(message[0]);
    r[2] =  Char_to_GBSCII(message[0]);
    r[3] =  Char_to_GBSCII(message[0]);
    r[4] =  Char_to_GBSCII(message[0]);
    r[5] =  Char_to_GBSCII(message[0]);
    r[6] =  Char_to_GBSCII(message[0]);
    r[7] =  Char_to_GBSCII(message[0]);
    r[8] =  Char_to_GBSCII(message[0]);
    r[9] =  Char_to_GBSCII(message[0]);
    r[10] = Char_to_GBSCII(message[0]);
    r[11] = Char_to_GBSCII(message[0]);
    r[12] = Char_to_GBSCII(message[0]);
    r[13] = Char_to_GBSCII(message[0]);
    r[14] = Char_to_GBSCII(message[0]);
    r[15] = Char_to_GBSCII(message[0]);
    r[16] = Char_to_GBSCII(message[0]);
    r[17] = Char_to_GBSCII(message[0]);
    r[18] = Char_to_GBSCII(message[0]);
    r[19] = Char_to_GBSCII(message[0]);
    r[20] = Char_to_GBSCII(message[0]);
    return r;
}


void PauseMenu(){

    unsigned char* PauseMessage = String_to_GBSCII("GAME PAUSED");
    set_win_tiles(0,0,5,1,PauseMessage);
    SHOW_BKG;
}

G:\GameBoy Game\Code>lcc.exe -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -c -o build/main.o main.c
GUIElements/PauseMenu.c(111):warning *** function 'String_to_GBSCII' implicit declaration
GUIElements/PauseMenu.c(111):warning *** function 'String_to_GBSCII' implicit declaration

G:\GameBoy Game\Code>lcc -Wa-l -Wl-m -Wl-j -DUSE_SFR_FOR_REG -o build/main.gb build/main.o

?ASlink-Warning-Undefined Global String_to_GBSCII referenced by module lcc84840

这是我由GameBoy开发套件提供的LCC编译器为GameBoy游戏所获得的。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

这是您定义函数的方式

unsigned char* String_To_GBSCII(const char* message)

这就是你的称呼方式

               String_to_GBSCII    

请注意tT的区别。

如果编译器说“ functionA”不存在,但是您正在查看自己认为的定义,并以“但是就在这里!”的方式查看,那么该使用编辑器的搜索功能了,测试编译器是否错过了您正在看的字母。