C++ ';' expected error before error?

Programming, for all ages and all languages.
Post Reply
Mehmetdev1
Posts: 23
Joined: Fri Apr 01, 2022 10:06 am
Location: Türkiye, Uşak/Merkez

C++ ';' expected error before error?

Post by Mehmetdev1 »

Merhaba, C++ ';' expected error before error? Hello, I'm getting what is the solution? I'm Posting Screenshot and Source Code.

interrupts.cpp:

Code: Select all

#include "interrupts.h"


void printf(char* str);

InterruptManager::GateDescriptor InterruptManager::interruptDescriptorTable[256];



void InterruptManager::SetInterruptDescriptorTableEntry(
        uint8_t interruptNumber,
        uint16_t codeSegmentSelectorOffset,
	void (*handler)(),
	uint8_t DescriptorPrivlegeLevel,
	uint8_t DescriptorType)
{
  
  const uint8_t IDT_DESC_PRESENT = 0x80;
  
  interruptDescriptorTable[interruptNumber].handlerAdressLowBits = ((uint32_t)handler) & 0xFFFF;
  interruptDescriptorTable[interruptNumber].handlerAdressLowBits = (((uint32_t)handler) >> 16) & 0xFFF;
  interruptDescriptorTable[interruptNumber].gdt_codeSegmentSelector = codeSegmentSelectorOffset
  interruptDescriptorTable[interrupt].access = IDT_DESC_PRESENT | ((DescriptorPrivilegeLevel & 3) << 5);
  interruptDescriptorTable[interruptNumber].reserved = 0;
  
 
}


InterruptManager::InterruptManager(GlobalDescriptorTable* gdt)
{
  uint16_t CodeSegment = gdt->CodeSegmentSelector();
  const uint8_t IDT_INTERRUPT_GATE = 0xE;
  
  for(uint16_t i = 0; i < 256; i++)
  SetInterruptDescriptorTableEntry(i, CodeSegment, &IgnoreInterruptRequest, 0, IDT_INTERRUPT_GATE);
  
  SetInterruptDescriptorTableEntry(0x20, CodeSegment, &HandleInterruptRequest0x00, 0, IDT_INTERRUPT_GATE);
  SetInterruptDescriptorTableEntry(0x21, CodeSegment, &HandleInterruptRequest0x01, 0, IDT_INTERRUPT_GATE);
  
  
    InterruptDescriptorTablePointer idt;
    idt.size = 256 * sizeof(GateDescriptor) -1;
    idt.base = (uint32_t)interruptDescriptorTable;
    asm volatile("lidt %0" : : "m" (idt));
}    
  
  
InterruptManager::~InterruptManager()
{
}

void InterruptManager::Activate()
{
 asm("sti");
}


uint32_t InterruptManager::handleInterrupt(uint8_t interruptNumber, uint32_t esp)
{
  printf(" INTERRUPT");
  
  return esp;
}

interrupts.h:

Code: Select all

#ifndef __INTERRUPTS_H
#define __INTERRUPTS_H

#include "types.h"
#include "port.h"
#include "gdt.h"

     class InterruptManager
     {
       
     protected:
   
       struct 	GateDescriptor
       {
	  uint16_t handlerAdressLowBits;
	  uint16_t gdt_codeSegmentSelector;
	  uint8_t reserved;
	  uint8_t acess;
	  uint16_t handlerAdressHighBits;
	  
	  
	  
       } __attribute__((packed));
       
       static GateDescriptor interruptDescriptorTable[256];
       
       struct InterruptDescriptorTablePointer
       {
	 uint16_t size;
	 uint32_t base;
	 
       } __attribute__((packed));
       
       static void SetInterruptDescriptorTableEntry(
       uint8_t interruptNumber, 
       uint16_t codeSegmentSelectorOfset,
       void (*handler)(),
       uint8_t DescriptorPrivlegeLevel,
       uint8_t DescriptorType
       );
       
     public:
       
       InterruptManager(GlobalDescriptorTable* gdt);
      ~InterruptManager();
      
      void Activate();
      
      static uint32_t handleInterrupt(uint8_t interruptNumber, uint32_t esp);
      
      static void IgnoreInterruptRequest();
      static void HandleInterruptRequest0x00();
      static void HandleInterruptRequest0x01();
     };
	 
	  
     
#endif
Attachments
Ekran görüntüsü 2022-05-04 165018.png
M. Alp
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: C++ ';' expected error before error?

Post by iansjack »

The error message is telling you exactly what the error is, and exactly where it is. To tell you more would be to spoon-feed you, and you are never going to learn the language if you have to ask for help every time you make a simple error. This is not the first time you have asked very elementary questions about errors when the message tells you exactly what the error is.

I don't wish to be rude, but I would suggest that you forget about OS development for the time being (are you just copy-pasting code from elsewhere?) and learn how to program in C++ using simple examples in a user environment. There are a number of books and courses on C++ programming that you might profitably study. Once you can confidently program in C++, and debug for yourself any errors that you make, you will be in a better position to look again at OS development.

I don't believe it is the place of this forum to teach beginners a programming language.
Ethin
Member
Member
Posts: 625
Joined: Sun Jun 23, 2019 5:36 pm
Location: North Dakota, United States

Re: C++ ';' expected error before error?

Post by Ethin »

I concur. You are asking elementary questions you should be able to solve on your own. We are not going to spoon-feed you all the answers to all your C++ questions. I'm not sure how long you've been programming in C++, but it doesn't seem like a long time considering the questions your asking. Get to a level where your comfortable in user environments, and then try your hand at OSDev again. I would strongly encourage you to ask your questions in a subreddit like cpp_questions, but do note that no C++ forum is going to spoon-feed you your code, nor are they going to be problem solvers for you. Part of programming is learning to solve problems on your own. We'll provide you with lots of advice, but we won't write your OS for you, nor will we help you find every little compiler error that you get.
Post Reply