最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

function overloading in C riscv64-elf-gcc vs clang - Stack Overflow

programmeradmin2浏览0评论

In an embedded riscv32 mcu's sdk I see the follow function overloading practice:

void FLASH_ROM_READ(uint32_t StartAddr, void *Buffer, uint32_t len);

void FLASH_ROM_READ(UINT32 StartAddr, PVOID Buffer, UINT32 len);

gcc compiles it fine. They are using riscv64-elf-gcc -march=rv32imac_zicsr -mabi=ilp32 -msmall-data-limit=8 compiler call in their makefile. And it sucessfully compiles.

However in my editor's (neovim) LSP (clangd) I get errors:

In included file: conflicting types for 'FLASH_ROM_READ'
[Ln 29, Col 6]Error occurred here
[Ln 29, Col 6]Previous declaration is here

How do I get the LSP to not raise this error?


EDIT - Here is my project structure

- {root}
    - vendor-lib
    - apps
        - hello-app
            - Makefile
            - compile_commands.json
            - src
                main.c
            - out

I think the problem is that vim/LSP doesn't honour the includes when I open library files. Do I have to generate another compile_commands.json at project root? If so how do I do that?


EDIT2: Actually it's not able to recognise these types uint32_t etc, inside header files, both in project and library folder..


EDIT3 Okay this comes from the discrepancy of the long type. In header it is defined:

typedef unsigned long           UINT32;

which is correct according to the riscv spec:

In both RV32 and RV64 C compilers, the C type int is 32 bits wide. longs and pointers, on the other hand, are both as wide as a integer register, so in RV32, both are 32 bits wide, while in RV64, both are 64 bits wide.

But why is it not working in clang? It expects the define to be typedef unsigned int for it to work.

发布评论

评论列表(0)

  1. 暂无评论