首页 > 解决方案 > 使用 -Wall 选项使用 SDCC 编译失败

问题描述

我正在用 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

解决方案


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

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

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

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

请参阅SDCC 编译器用户指南(版本 4.1.12),第 3.3.4 节。


推荐阅读