c - C中同一行的“多个定义”
问题描述
所以我正在制作一个名为reboot的函数,但是当我定义它时,编译器会给出一个错误,就像函数已经定义一样。
这是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
这是我的Makefile:
解决方案
问题是我的程序集文件名为 bios.asm,因此它创建了两个 bios.o,这就是导致错误的原因(感谢 Eric Postpischil)
推荐阅读
- qt - 如果任何一个 QML 项目自行更新,QML 会重新绘制整个屏幕吗?
- spring-boot - 仅在 Intellij 调试器中检测到 Mockito 未完成的存根异常
- react-native - 在抽屉中使用本机多屏反应
- android - 颤振流显示错误类型“_TypeError”不是“字符串”类型的子类型
- flutter - 如何使用 Flutter hive 创建标记为 fabourite 按钮?
- javascript - 如何添加条件删除类 -
- c# - 如何制作一个从C#中的列表返回值的函数
- python - DataSpell (JetBrains) 在 Jupyter 笔记本中显示错误:“您的浏览器不支持 WebGL ...”
- flutter - 无法在 Flutter Video Player 中播放 IPTV 频道
- nlp - `pylucene` 和 `pyhanlp` 之间有冲突吗?