簡體   English   中英

C 中同一行的“多個定義”

[英]“Multiple Definitions” at the same line in C

所以我正在制作一個名為 reboot 的 function,但是當我定義它時,編譯器會給出一個錯誤,例如 function 已經定義。

這是bios.c:

#include "bios.h"
#include <stdint.h>
#include <libasm/asm.h>
void reboot()
{
    uint8_t good = 0x02;
    while (good & 0x02)
        good = EmeraldASM_inb(0x64);
    EmeraldASM_outb(0x64, 0xFE);
    asm volatile("hlt");
}

這是bios.h:

#ifndef BIOSPOWER_H
#define BIOSPOWER_H
#pragma once
void reboot();
extern void shutdown();
#endif

這是編譯器錯誤: /home/abbix/Documents/Projects/emerald/src/firmware/bios.c:5: multiple definition of `reboot'; src/firmware/bios.o:/home/abbix/Documents/Projects/emerald/src/firmware/bios.c:5: first defined here /home/abbix/Documents/Projects/emerald/src/firmware/bios.c:5: multiple definition of `reboot'; src/firmware/bios.o:/home/abbix/Documents/Projects/emerald/src/firmware/bios.c:5: first defined here

這是我的 Makefile:

https://pastebin.com/xCcQEtx3

問題是我的程序集文件名為 bios.asm,因此它創建了兩個 bios.o,這就是導致錯誤的原因(感謝 Eric Postpischil)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM