链表文件中有引入 #include C 头文件,在编绎是不识别如何处理有没有方案?
d:/program files (x86)/rv32-toolchain/rv32-v2/bin/../lib/gcc/riscv32-elf/10.2.0/../../../../riscv32-elf/bin/ld.exe:f:/bluetrum/AB2026/sdk_ab202x_beta_s349_20230829/app/project/example/led/ram.ld:1: ignoring invalid character `#' in expression
d:/program files (x86)/rv32-toolchain/rv32-v2/bin/../lib/gcc/riscv32-elf/10.2.0/../../../../riscv32-elf/bin/ld.exe:f:/bluetrum/AB2026/sdk_ab202x_beta_s349_20230829/app/project/example/led/ram.ld:1: syntax error
collect2.exe: error: ld returned 1 exit status
关于链表文件.ld
6 days later
- Edited
linker script 是不能直接支持 # 指令的
如果你需要使用 # 预处理指令,需要经过 预处理器 进行预处理,然后在传递给 ld.exe
https://blog.csdn.net/ytmayer/article/details/44997837
方法:
新建一个 prebuild task 任务,添加以下命令
"${CompilerPrefix}gcc" -xc -E -P ./<相对路径>/example/led/ram.ld -o ./build/ram.lds
注意:如果你要用 #include 指令,那么上述命令里要加 -I 用于添加头文件搜索路径
然后修改 构建器选项 的 链接脚本路径,改为:./build/ram.lds 就行了