sdcc - 使用 -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 没有-Wall
选项。您应该从CFLAGS = -Wall -I.
Makefile 中删除它。
它也没有替代品。有选项--less-pedantic
和-Werror
,分别为您提供更少的警告,或将警告视为错误,但没有用于创建更多警告的选项。
手册提到--more-pedantic
,但是
实际上,这不是 SDCC 编译器选项,但如果您想要更多警告,您可以使用专门用于语法检查的单独工具 [...]
请参阅SDCC 编译器用户指南(版本 4.1.12),第 3.3.4 节。
推荐阅读
- python - 有没有一种方法可以检测某个像素的 RGB 值并在 if 条件下使用它?
- c# - SignalR 无法加载资源
- perl - 如何使用哈希引用计算数组的重复值
- php - 正则表达式不适用于某些用户输入
- javascript - 如何创建具有多个键和元素的单个对象?
- java - Maven pom继承和覆盖父子模块
- c - 将不透明的结构定义放入单独的头文件中
- sql - 在 SQL 表中,我有一个用于删除列的 sql 脚本,它给出错误无效列不存在
- java - com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java) 与 ChromeDriver 和 Chrome 使用 Selenium 和 Java
- c# - ASP.Net Core 2.2 Web API 排队后台任务