当我尝试编译C代码,其中包括另一C头我得到这个错误以前声明:错误:函数声明“ms_abi”这里没有调用约定(铛)
x86_64-uefi/../../libk/string.h:9:10: error: function declared 'ms_abi' here was
previously declared without calling convention
KABI int memcmp(const void *d1, const void *d2, uint64_t len);
^
x86_64-uefi/../../libk/string.h:9:10: note: previous declaration is here
编译器是铛和涉及的文件如下:
memcmp.c
#include "../string.h"
KABI int memcmp(const void *d1, const void *d2, uint64_t len) {
const uint8_t *d1_ = d1, *d2_ = d2;
for(uint64_t i = 0; i < len; i += 1, d1_++, d2_++){
if(*d1_ != *d2_) return *d1_ < *d2_ ? -1 : 1;
}
return 0;
}
string.h
#pragma once
#include "systemapi.h"
#include "typedefs.h"
KABI int memcmp(const void *d1, const void *d2, uint64_t len);
systemapi.h
(类型定义刚刚定义uintx_t类型)
#pragma once
#define KABI __attribute__((ms_abi))
另一个报头,其包括string.h
,libk.h
#pragma once
#include "string.h"
#include "systemapi.h"
#include "typedefs.h"
这包括lib.h的文件和报告编译时错误, main.c
(但当与lib.h
连接时,所有文件均报告错误)
KABI void arch_main(void)
{
// The function does not uses memcmp, just uses the KABI part of lib.h
// Calling the whole lib.h is a convention
}
个
标志的编译器:-I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/efi/protocol -fno-stack-protector -fpic -fshort-wchar -mno-red-zone -DHAVE_USE_MS_ABI -c main.c -o main.o
@MichaelPetch我改变了顺序,但什么都没有改变,同样的错误信息 – Rottenheimer2
我在github上的项目创建一个分支,所以你可以看到更多的方面:https://github.com/TheStr3ak5/CKA/tree/TheStr3ak5- newABI,只要在BUILD文件后面建立这个分支,你就会看到错误。 – Rottenheimer2
@MichaelPetch是的,你是对的,它解决了我的问题,谢谢! – Rottenheimer2