可能大伙不怎么用C++。不确定是不是和ARMGCC 12.3 版本有关系,默认会生成一堆像是和异常处理相关的代码,一个HelloWorld 项目一编译就有差不多5KB 大小。加上这两个参数,5KB 减少到了1KB,
-fno-rtti禁用RTTI,主要会把
dynamic_cast的功能废掉;
-fno-exceptions` 禁用异常。这俩都是嵌入式代码里不怎么用得到的动态功能,大把的人还是纯C 语言写项目,所以如果是用platformio,这两个参数默认就加上了。
另外话说,升级到ARMGCC 12.3,编译出来一堆警告:
c:/users/chris/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/users/chris/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.3.1/thumb/v6-m/nofp\libc_nano.a(libc_a-closer.o): in function `_close_r':
closer.c:(.text._close_r+0xc): warning: _close is not implemented and will always fail
c:/users/chris/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/users/chris/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.3.1/thumb/v6-m/nofp\libc_nano.a(libc_a-lseekr.o): in function `_lseek_r':
lseekr.c:(.text._lseek_r+0x10): warning: _lseek is not implemented and will always fail
c:/users/chris/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/users/chris/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.3.1/thumb/v6-m/nofp\libc_nano.a(libc_a-readr.o): in function `_read_r':
readr.c:(.text._read_r+0x10): warning: _read is not implemented and will always fail
c:/users/chris/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: c:/users/chris/scoop/apps/gcc-arm-none-eabi/current/bin/../lib/gcc/arm-none-eabi/12.3.1/thumb/v6-m/nofp\libc_nano.a(libc_a-writer.o): in function `_write_r':
writer.c:(.text._write_r+0x10): warning: _write is not implemented and will always fail
stackoverflow 上看到有人说,加上--specs=nosys.specs
就OK,但是我这里还是不行。