Conflicting types but function types are the same

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
aether123
Posts: 18
Joined: Fri Jun 20, 2025 5:23 pm
Libera.chat IRC: aether123

Conflicting types but function types are the same

Post by aether123 »

I am getting these errors from my code:

Code: Select all

In file included from src/kernel/interrupts/idt.c:2:
src/kernel/interrupts/idt.h:19:25: warning: 'struct InterruptRegisters' declared inside parameter list will not be visible outside of this definition or declaration
   19 | void isr_handler(struct InterruptRegisters* regs);
      |                         ^~~~~~~~~~~~~~~~~~
src/kernel/interrupts/idt.c:135:6: error: conflicting types for 'isr_handler'; have 'void(struct InterruptRegisters *)'
  135 | void isr_handler(struct InterruptRegisters* regs){
      |      ^~~~~~~~~~~
src/kernel/interrupts/idt.h:19:6: note: previous declaration of 'isr_handler' with type 'void(struct InterruptRegisters *)'
   19 | void isr_handler(struct InterruptRegisters* regs);
      |      ^~~~~~~~~~~
make: *** [Makefile:18: includes] Error 1
I've been implementing my IDT, and it should be working fine, but it's saying that my function definitions have conflicting types, any help is much appreciated, thanks in advance

My project files: https://github.com/i-love-winter/SolsticeOS
Capybara Gymastics is one of the most prestigious Olympic sports
nullplan
Member
Member
Posts: 1908
Joined: Wed Aug 30, 2017 8:24 am

Re: Conflicting types but function types are the same

Post by nullplan »

The warning tells you what the problem is. Might I suggest getting some more experience with C in userspace before embarking on an OS journey? All of your questions so far have betrayed not just lack of knowledge in operating systems, but also lack of knowledge and experience with the language, and no willing to even just Google the error messages you are getting.
Carpe diem!
User avatar
iansjack
Member
Member
Posts: 4811
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Conflicting types but function types are the same

Post by iansjack »

Perhaps not the most obvious of error messages.

Concentrate on the warning, not the errors. It's a good example of why you should be sure that you understand the reason for every warning message that you get.
aether123
Posts: 18
Joined: Fri Jun 20, 2025 5:23 pm
Libera.chat IRC: aether123

Re: Conflicting types but function types are the same

Post by aether123 »

Thankyou for your advice, and I will learn and get more experience with c before I continue this project, and hopefully understand things a lot more
Capybara Gymastics is one of the most prestigious Olympic sports
MichaelPetch
Member
Member
Posts: 832
Joined: Fri Aug 26, 2016 1:41 pm
Libera.chat IRC: mpetch

Re: Conflicting types but function types are the same

Post by MichaelPetch »

You get that warning because you haven't actually defined the struct `InterruptRegisters` before using it. To fix that you should include utils.h at the top of idt.h with

Code: Select all

#include "../utils/utils.h"
aether123
Posts: 18
Joined: Fri Jun 20, 2025 5:23 pm
Libera.chat IRC: aether123

Re: Conflicting types but function types are the same

Post by aether123 »

Thankyou!
Capybara Gymastics is one of the most prestigious Olympic sports
Post Reply