Ndless编译问题

时间:2019-03-30 03:13:04

标签: c compiler-errors object-files ti-nspire

我有一个包含一些代码的文件,它引用一个库(#include << em> lib >)。我使用 nspire-tools new(文件)创建了 makefile ,并在终端中使用命令 make 编译了文件(colors.c)。将引发有关缺少引用/库的错误,并且不会创建已编译文件(.elf,.o,.prg.tns和.tns)。

user@user-System-Product-Name:~/Ndless/ndless-sdk/samples/colors$ make
nspire-gcc -Wall -W -marm -Os -c colors.c -o colors.o
colors.c: In function ‘main’:
colors.c:6:2: warning: implicit declaration of function ‘lcd_incolor’; did you mean ‘lcd_init’? [-Wimplicit-function-declaration]
  lcd_incolor();
  ^~~~~~~~~~~
  lcd_init
In file included from /home/rico/Ndless/ndless-sdk/bin/../include/os.h:24,
                 from colors.c:1:
/home/rico/Ndless/ndless-sdk/bin/../include/libndls.h:164:95: error: expected ‘;’ before ‘}’ token
 ASE_ADDRESS ({"SCREEN_BASE_ADDRESS got removed in favor of the lcd_blit API."})
                                                                              ^

colors.c:7:37: note: in expansion of macro ‘SCREEN_BASE_ADDRESS’
  volatile unsigned char *scr_base = SCREEN_BASE_ADDRESS;
                                     ^~~~~~~~~~~~~~~~~~~
/home/rico/Ndless/ndless-sdk/bin/../include/libndls.h:164:30: warning: pointer targets in initialization of ‘volatile unsigned char *’ from ‘char *’ differ in signedness [-Wpointer-sign]
  #define SCREEN_BASE_ADDRESS ({"SCREEN_BASE_ADDRESS got removed in favor of the lcd_blit API."})
                              ^
colors.c:7:37: note: in expansion of macro ‘SCREEN_BASE_ADDRESS’
  volatile unsigned char *scr_base = SCREEN_BASE_ADDRESS;
                                     ^~~~~~~~~~~~~~~~~~~
colors.c:9:22: error: ‘SCREEN_BYTES_SIZE’ undeclared (first use in this function); did you mean ‘SCREEN_BASE_ADDRESS’?
  unsigned scr_size = SCREEN_BYTES_SIZE;
                      ^~~~~~~~~~~~~~~~~
                      SCREEN_BASE_ADDRESS
colors.c:9:22: note: each undeclared identifier is reported only once for each function it appears in
Makefile:30: recipe for target 'colors.o' failed
make: *** [colors.o] Error 1

我正在编译的该文件是Ndless SDK中包含的一个示例代码片段,并且我已将该示例项目中包含的其他文件放了下来,以便可以测试编译主文件。

由于这些示例已经预编译,因此我决定查看是否将原始.o文件放入与.c文件完全相同的目录文件夹中。我使用上述相同的命令进行了编译,并且没有抛出致命错误(只是抛出了misc api错误)。

user@user-System-Product-Name:~/Ndless/ndless-sdk/samples/colors$ make
mkdir -p .
nspire-ld colors.o -o colors.c.elf 
genzehn --input colors.c.elf --output colors.c.tns.zehn --name "colors.c"
Warning: Your application does not appear to support 240x320px displays!
If it does, override with '--240x320-support true'.
make-prg colors.c.tns.zehn colors.c.tns
rm colors.c.tns.zehn

.o文件似乎阻止了 make 绕过创建新的.o文件,而是继续生成其他文件?我该如何解决这些错误并仅从colors.c生成必要的文件?

colors.c

#include <os.h>

int main(void) {
    if (!has_colors)
        return 0;
    lcd_incolor();
    volatile unsigned char *scr_base = SCREEN_BASE_ADDRESS;
    volatile unsigned char *ptr;
    unsigned scr_size = SCREEN_BYTES_SIZE;
    // See http://en.wikipedia.org/wiki/High_color -> "16-bit high color" for the encoding of the screen buffer
    for (ptr = scr_base; ptr < scr_base + scr_size / 3; ptr += 2)
        *(volatile unsigned short*)ptr = 0b1111100000000000;
    for (; ptr < scr_base + scr_size * 2 / 3; ptr += 2)
        *(volatile unsigned short*)ptr = 0b0000011111100000;
    for (; ptr < scr_base + scr_size; ptr += 2)
        *(volatile unsigned short*)ptr = 0b0000000000011111;
    wait_key_pressed();
    return 0;
}

0 个答案:

没有答案