Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7545277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:53:10+00:00 2026-05-30T08:53:10+00:00

I’m having a problem with a struct when trying to do this in C++

  • 0

I’m having a problem with a struct when trying to do this in C++ (visual studio):

memoria.cpp

  struct readMem {
    UINT32 startAdress;
    UINT32 endAdress;
    UINT8(*memoryHandler) (UINT32);
    void *pUserData;
};

struct writeMem {
    UINT32 startAdress;
    UINT32 endAdress;
    void (*memoryHandler) (UINT32, UINT8);
    void *pUserData;
};



 void memoria::writeRAMBankEnable(UINT32 a, UINT8 b) {
}

void memoria::writeROMBankSelect(UINT32 a, UINT8 b) {
}

void memoria::writeRAMROMModeSelect(UINT32 a, UINT8 b) {
}

void memoria::writeVRAM(UINT32 a, UINT8 b) {
}

void memoria::writeSRAM(UINT32 a, UINT8 b) {
}

void memoria::writeRAM(UINT32 a, UINT8 b) {
}

void memoria::writeERAM(UINT32 a, UINT8 b) {
}

void memoria::writeSprite(UINT32 a, UINT8 b) {
}

void memoria::writeIOM(UINT32 a, UINT8 b) {
}

void memoria::writeHRAM(UINT32 a, UINT8 b) {
}


struct writeMem implWriteMem[] = {
    { 0x0000, 0x1FFF, writeRAMBankEnable, NULL},
    { 0x4000, 0x5FFF, writeROMBankSelect, NULL},
    { 0x6000, 0x7FFF, writeRAMROMModeSelect, NULL},
    { 0x8000, 0x9FFF, writeVRAM, NULL},
    { 0xA000, 0xBFFF, writeSRAM, NULL},
    { 0xC000, 0xDFFF, writeRAM, NULL},
    { 0xE000, 0xFDFF, writeERAM, NULL},
    { 0xFE00, 0xFE9F, writeSprite, NULL},
    { 0xFF00, 0xFF7F, writeIOM, NULL},
    { 0xFF80, 0xFFFF, writeHRAM, NULL},
    { (UINT32) - 1, (UINT32) - 1, NULL, NULL}
};

    memoria.h    

        #pragma once

#include <stdlib.h>
#include <stdio.h>
#include "defs.h"

ref class memoria
{
public:
    memoria(void);

private:
    FILE *file;
    UINT8 *mem;
public:

    void writeRAMBankEnable(UINT32, UINT8);

    void writeROMBankSelect(UINT32, UINT8);

    void writeRAMROMModeSelect(UINT32, UINT8);

    void writeVRAM(UINT32, UINT8);

    void writeSRAM(UINT32, UINT8);

    void writeRAM(UINT32, UINT8);

    void writeERAM(UINT32, UINT8);

    void writeSprite(UINT32, UINT8);

    void writeIOM(UINT32, UINT8);

    void writeHRAM(UINT32, UINT8);

    UINT8 readRAMBankEnable(UINT32);

    UINT8 readROMBankSelect(UINT32);

    UINT8 readRAMROMModeSelect(UINT32);

    UINT8 readVRAM(UINT32);

    UINT8 readSRAM(UINT32);

    UINT8 readRAM(UINT32);

    UINT8 readERAM(UINT32);

    UINT8 readSprite(UINT32);

    UINT8 readIOM(UINT32);

    UINT8 readHRAM(UINT32);


    void Meminitialize();
    void MemcleanUp();

    void writeByte(UINT32, UINT8);
    UINT8 readByte(UINT32);

    void writeWord(UINT32, UINT16);
    UINT16 readWord(UINT32);
};

Visual studio c++ gives me this errors:

1>memoria.cpp(75): error C2065: ‘writeRAMBankEnable’ : undeclared identifier

1>memoria.cpp(76): error C2065: ‘writeROMBankSelect’ : undeclared identifier

1>memoria.cpp(77): error C2065: ‘writeRAMROMModeSelect’ : undeclared identifier

1>memoria.cpp(78): error C2065: ‘writeVRAM’ : undeclared identifier

1>memoria.cpp(79): error C2065: ‘writeSRAM’ : undeclared identifier

1>memoria.cpp(80): error C2065: ‘writeRAM’ : undeclared identifier

1>memoria.cpp(81): error C2065: ‘writeERAM’ : undeclared identifier

1>memoria.cpp(82): error C2065: ‘writeSprite’ : undeclared identifier

1>memoria.cpp(83): error C2065: ‘writeIOM’ : undeclared identifier

1>memoria.cpp(84): error C2065: ‘writeHRAM’ : undeclared identifier

1>memoria.cpp(169): error C2065: ‘implReadMem’ : undeclared identifier

1>memoria.cpp(179): error C2065: ‘implReadMem’ : undeclared identifier

For the record, I have declared all the functions in my memoria.h, all but the structs and the implWriteMem[], of course.
Anyway, how can I solve that?

P.S. It worked quite well in pure C.

Thanks !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:53:11+00:00Added an answer on May 30, 2026 at 8:53 am
    { 0x0000, 0x1FFF, writeRAMBankEnable, NULL},
    

    Did you perhaps mean

    { 0x0000, 0x1FFF, &memoria::writeRAMBankEnable, NULL},
    

    You have to include the class name when referring to a member, except within the class. And when making a pointer to a member function, you always need the class name.

    The best solution is to use the polymorphism features built into the language:

    ref struct MemoryRegion abstract
    {
         virtual uint8_t Read( uint32_t address ) = 0;
         virtual void Write( uint32_t address, uint8_t value ) = 0;
         const uint32_t start_address, end_address;
    protected:
         MemoryRegion( uint32_t start, uint32_t end ) : start_address(start), end_address(end) {}
    };
    
    ref struct SRAM : MemoryRegion
    {
         SRAM( uint32_t start, uint32_t end ) : MemoryRegion(start, end) {}
         virtual uint8_t Read(uint32_t address);
         virtual void Write(uint32_t address, uint8_t value);
    };
    
    ref struct RAM : MemoryRegion
    {
         RAM( uint32_t start, uint32_t end ) : MemoryRegion(start, end) {}
         virtual uint8_t Read(uint32_t address);
         virtual void Write(uint32_t address, uint8_t value);
    };
    
    ref struct VRAM : MemoryRegion
    {
         VRAM( uint32_t start, uint32_t end ) : MemoryRegion(start, end) {}
         virtual uint8_t Read(uint32_t address);
         virtual void Write(uint32_t address, uint8_t value);
    };
    

    and so on. Then you can make an array of handles to the base type, and fill in all kinds of behavior-specific classes:

    array<MemoryRegion^>^ memories = gcnew array<MemoryRegion^>(10);
    memories[0] = gcnew SRAM(0xA000, 0xBFFF);
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.