【问题标题】:Compiling with SDCC fails with -Wall option使用 -Wall 选项使用 SDCC 编译失败
【发布时间】:2021-12-09 16:41:17
【问题描述】:

我正在用 SDCC 编译一个 8051 项目,但 Makefile 有问题,来源如下:

TARGET  = test
CC      = sdcc
CFLAGS  = -Wall -I.
RM      = rm -rf
SRCS    = $(wildcard *.c)
RELS    = $(patsubst %.c,%.rel,$(SRCS))

$(TARGET).bin: $(TARGET).hex
        objcopy -I ihex -O binary $< $@

$(TARGET).hex: $(TARGET).ihx
        packihx $< > $@

$(TARGET).ihx: $(RELS)
        @echo Linking ...
        $(CC) $(CFLAGS) $< -o $@
        @echo Build finish!
%.rel: %.c
        @echo Compiling ...
        $(CC) $(CFLAGS) -c $< -o $@

.PHONY: clean
clean:
        @echo Removing ...
        $(RM) *.rel *.ihx *.lk *.lst *.map *.mem *.rst *.sym *.asm $(TARGET)
        @echo Removed!

当我运行make 时出现错误:

minh@PCDESIGN:~/workspaces/programMSC51/test$ make
Compiling ...
sdcc -Wall -I. -c main.c -o main.rel

sdas Assembler V02.00 + NoICE + SDCC mods  (Intel 8051)


Copyright (C) 2012  Alan R. Baldwin
This program comes with ABSOLUTELY NO WARRANTY.

Usage: [-Options] file
Usage: [-Options] outfile file1 [file2 file3 ...]
  -d   Decimal listing
  -q   Octal   listing
  -x   Hex     listing (default)
  -g   Undefined symbols made global
  -a   All user symbols made global
  -b   Display .define substitutions in listing
  -bb  and display without .define substitutions
  -c   Disable instruction cycle count in listing
  -j   Enable NoICE Debug Symbols
  -y   Enable SDCC  Debug Symbols
  -l   Create list   file/outfile[.lst]
  -o   Create object file/outfile[.rel]
  -s   Create symbol file/outfile[.sym]
  -p   Disable automatic listing pagination
  -u   Disable .list/.nlist processing
  -w   Wide listing format for symbol table
  -z   Disable case sensitivity for symbols
  -f   Flag relocatable references by  `   in listing file
  -ff  Flag relocatable references by mode in listing file
  -I   Add the named directory to the include file
       search path.  This option may be used more than once.
       Directories are searched in the order given.

removing
make: *** [Makefile:22: main.rel] Error 1

我该如何解决这个问题?

【问题讨论】:

    标签: sdcc


    【解决方案1】:

    与其他编译器不同,SDCC 没有-Wall 选项。您应该将其从 Makefile 中的 CFLAGS = -Wall -I. 中删除。

    它也没有替代品。有--less-pedantic 和-Werror 选项,分别为您提供更少 个警告,或将警告视为错误,但没有用于创建更多 个警告的选项。

    手册中提到了--more-pedantic,但是

    实际上这不是 SDCC 编译器选项,但如果您想要更多警告,您可以使用专门用于语法检查的单独工具 [...]

    参见SDCC Compiler User Guide(版本 4.1.12),第 3.3.4 节。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-12-05
    • 1970-01-01
    • 2021-02-21
    • 1970-01-01
    • 1970-01-01
    • 2021-10-28
    • 2021-10-14
    • 2011-12-21
    相关资源
    最近更新 更多