Sure, I'd be happy to help with your compiler question! Please go ahead and ask.
User
Compiling src/devices/bus/gameboy/mbc6.cpp...
../../../../../src/devices/bus/gameboy/mbc6.cpp: In constructor 'bus::gameboy::{anonymous}::mbc6_device::mbc6_device(const machine_config&, const char*, device_t*, u32)':
../../../../../src/devices/bus/gameboy/mbc6.cpp:133:21: error: use of deleted function 'memory_view::memory_view(const memory_view&)'
133 | m_flash_writable(0U)
| ^
In file included from D:/mingw/mame/src/lib/util/coretmpl.h:15,
from D:/mingw/mame/src/emu/emucore.h:27,
from ../../../../../src/emu/emu.h:33:
D:/mingw/mame/src/emu/emumem.h:2614:18: note: declared here
2614 | DISABLE_COPYING(memory_view);
| ^~~~~~~~~~~
D:/mingw/mame/src/osd/osdcomm.h:118:2: note: in definition of macro 'DISABLE_COPYING'
118 | TYPE(const TYPE &) = delete;
| ^~~~
optional.make:9741: recipe for target '../../../../mingw-gcc/obj/x32/Release/src/devices/bus/gameboy/mbc6.o' failed
make[2]: *** [../../../../mingw-gcc/obj/x32/Release/src/devices/bus/gameboy/mbc6.o] Error 1
makefile:103: recipe for target 'optional' failed
make[1]: *** [optional] Error 2
makefile:1147: recipe for target 'windows_x86' failed
make: *** [windows_x86] Error 2
Assistant
Based on the error messages you've provided, it looks like the issue is with an attempt to copy an instance of , which has been explicitly deleted (made illegal) through the use of macro. The macro is typically used to delete the copy constructor and the copy assignment operator to prevent the copying of objects. This is a common practice in C++ to avoid unintended or inefficient copies of objects, especially those that manage resources or are intended to have a unique instance.
User
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
The error is thrown from this line of your mbc6_device constructor initialization:
cpp
m_flash_writable(0U)
This suggests that m_flash_writable is being initialized in a way that involves copying a memory_view object which is not allowed. Without seeing the definition of m_flash_writable and its context in your code, it's a bit difficult to provide a precise solution, but here are a few general approaches to resolving this issue:
Initialization without Copying: Ensure that m_flash_writable (and any similar problematic variables) are initialized without attempting to copy a memory_view. This might involve directly initializing them with their intended values or using move semantics if applicable.
Check memory_view Use: Since memory_view cannot be copied, you'll need to ensure that any use of memory_view does not imply copying. For example, if m_flash_writable is supposed to hold a view of memory, consider initializing it directly in a manner that doesn't involve copying or use pointers/references to memory_view objects instead of copying them.
Reconsider the Design: If memory_view objects need to be shared or re-assigned, consider redesigning the relevant parts of your system. Perhaps use pointers or references to memory_view instead of value instances or look into other ways of managing access to memory_view without copying it.
Move Semantics: If a class needs to be "moved" instead of copied (and the class supports it), you might avoid the error by using std::move, though this really depends on the context and whether it's applicable to your specific use case.
Without more context or the actual code, these suggestions are relatively general. If you need a more detailed answer, please provide additional information about the m_flash_writable initialization and how memory_view is used within your code.
Here is the m_flash_writable initialization and how memory_view is used: #include "emu.h"
#include "mbc6.h"
std::error_condition mbc6_device::load(std::string &message)
{
// first check that ROM/RAM regions are supportable
set_bank_bits_rom(7);
if (!check_rom(message) || !check_ram(message))
return image_error::BADSOFTWARE;
code
// install views for ROM/flash and RAM
cart_space()->install_view(0x4000, 0x5fff, m_view_rom[0]);
cart_space()->install_view(0x6000, 0x7fff, m_view_rom[1]);
cart_space()->install_view(0xa000, 0xbfff, m_view_ram);
// set up ROM and RAM as appropriate
install_rom(*cart_space(), m_view_rom[0][0], m_view_rom[1][0]);
install_ram();
// install memory controller handlers
cart_space()->install_write_handler(
0x0000, 0x03ff,
emu::rw_delegate(*this, FUNC(mbc6_device::enable_ram)));
cart_space()->install_write_handler(
0x0400, 0x07ff,
emu::rw_delegate(*this, FUNC(mbc6_device::bank_switch_ram<0>)));
cart_space()->install_write_handler(
0x0800, 0x0bff,
emu::rw_delegate(*this, FUNC(mbc6_device::bank_switch_ram<1>)));
cart_space()->install_write_handler(
0x0c00, 0x0fff,
emu::rw_delegate(*this, FUNC(mbc6_device::enable_flash)));
cart_space()->install_write_handler(
0x1000, 0x1000, // TODO: what range does this actually respond to?
emu::rw_delegate(*this, FUNC(mbc6_device::enable_flash_write)));
cart_space()->install_write_handler(
0x2000, 0x27ff, 0x0000, 0x0000, 0x1000,
emu::rw_delegate(*this, FUNC(mbc6_device::bank_switch_rom)));
cart_space()->install_write_handler(
0x2800, 0x2fff, 0x0000, 0x0000, 0x1000,
emu::rw_delegate(*this, FUNC(mbc6_device::select_flash)));
// install Flash handlers
m_view_rom[0][1].install_readwrite_handler(
0x4000, 0x5fff,
emu::rw_delegate(*this, FUNC(mbc6_device::read_flash<0>)),
emu::rw_delegate(*this, FUNC(mbc6_device::write_flash<0>)));
m_view_rom[1][1].install_readwrite_handler(
0x6000, 0x7fff,
emu::rw_delegate(*this, FUNC(mbc6_device::read_flash<1>)),
emu::rw_delegate(*this, FUNC(mbc6_device::write_flash<1>)));
// all good
return std::error_condition();
if (!m_flash_select[bank])
{
if (BIT(data, 7))
{
LOG(
"%s: ROM bank %s unmapped\n",
machine().describe_context(),
bank ? "high" : "low");
m_view_rom[bank].disable(); // is there a chip select for a second program ROM?
}
else
{
m_view_rom[bank].select(0);
}
}
if (bank)
set_bank_rom_high(data & 0x7f);
else
set_bank_rom_low(data & 0x7f);
}
void mbc6_device::select_flash(offs_t offset, u8 data)
{
auto const bank(BIT(offset, 12));
m_flash_select[bank] = BIT(data, 3);
if (m_flash_select[bank])
{
LOG(
"%s: Flash bank %s selected (%s)\n",
machine().describe_context(),
bank ? "high" : "low",
m_flash_enable ? "enabled" : "disabled");
if (m_flash_enable)
m_view_rom[bank].select(1);
else
m_view_rom[bank].disable();
}
else if (BIT(m_bank_sel_rom[bank], 7))
{
LOG(
"%s: ROM bank %s unmapped\n",
machine().describe_context(),
bank ? "high" : "low");
m_view_rom[bank].disable(); // is there a chip select for a second program ROM?
}
else
{
LOG(
"%s: ROM bank %s selected\n",
machine().describe_context(),
bank ? "high" : "low");
m_view_rom[bank].select(0);
}
code
// game writes 0xc6 when selecting ROM during boot - what do the other bits do?
if (data & ~0x08)
{
LOG(
"%s: ROM/Flash select %s with unknown bits set 0x%02X\n",
machine().describe_context(),
bank ? "high" : "low",
data);
}
}
template
void mbc6_device::bank_switch_ram(u8 data)
{
if (m_bank_mask_ram)
{
data &= m_bank_mask_ram;
LOG(
"%s: Set RAM bank %s = 0x%04X\n",
machine().describe_context(),
Bank ? "high" : "low",
data * PAGE_RAM_SIZE);
m_bank_ram[Bank]->set_entry(data);
}
}
void mbc6_device::enable_flash(u8 data)
{
// game seems to always set Flash write enable before changing this
if (m_flash_writable)
{
m_flash_enable = BIT(data, 0);
if (m_flash_enable)
{
LOG("%s: Flash enabled\n", machine().describe_context());
if (m_flash_select[0])
m_view_rom[0].select(1);
if (m_flash_select[1])
m_view_rom[1].select(1);
}
else
{
LOG("%s: Flash disabled\n", machine().describe_context());
if (m_flash_select[0])
m_view_rom[0].disable();
if (m_flash_select[1])
m_view_rom[1].disable();
}
code
if (data & ~0x01)
{
logerror(
"%s: Flash enable with unknown bits set 0x%02X\n",
machine().describe_context(),
data);
}
}
else
{
logerror(
"%s: Flash enable 0x%02X when Flash write disabled\n",
machine().describe_context(),
data);
}
}
void mbc6_device::enable_flash_write(u8 data)
{
// FIXME: this should also control whether Flash can be erased/written
m_flash_writable = BIT(data, 0);
LOG(
"%s: Flash write %s\n",
machine().describe_context(),
m_flash_writable ? "enabled" : "disabled");
code
if (data & ~0x01)
{
logerror(
"%s: Flash write enable with unknown bits set 0x%02X\n",
machine().describe_context(),
data);
}
bool mbc6_device::check_ram(std::string &message)
{
memory_region *const ramregion(cart_ram_region());
memory_region *const nvramregion(cart_nvram_region());
auto const rambytes(ramregion ? ramregion->bytes() : 0);
auto const nvrambytes(nvramregion ? nvramregion->bytes() : 0);
if (rambytes && nvrambytes && ((rambytes & (PAGE_RAM_SIZE - 1)) || (nvrambytes & (PAGE_RAM_SIZE - 1)) || ((nvrambytes - 1) & nvrambytes)))
{
message = "Unsupported cartridge RAM size (if not all RAM is battery-backed, battery backed RAM size must be a power of two no smaller than 4 KiB, and total RAM size must be a multiple of 4 KiB)";
return false;
}
code
auto const ramtotal(rambytes + nvrambytes);
if (((PAGE_RAM_SIZE < ramtotal) && (ramtotal & (PAGE_RAM_SIZE - 1))) && ((u32(PAGE_RAM_SIZE) << 3) < ramtotal))
{
message = "Unsupported cartridge RAM size (must be no larger than 4 KiB, or a multiple of 4 KiB no larger than 32 KiB)";
return false;
}
return true;
DEFINE_DEVICE_TYPE_PRIVATE(GB_ROM_MBC6, device_gb_cart_interface, bus::gameboy::mbc6_device, "gb_rom_mbc6", "Game Boy MBC6 Cartridge")
The error you're encountering is due to attempting an initialization or an operation that implies the use of the copy constructor for memory_view, which you can't do because the copy constructor for memory_view has been deleted (as indicated by the use of DISABLE_COPYING(memory_view) macro in the memory_view class).
Having a look through your mbc6_device constructor initialization list, nothing there directly suggests an attempt to copy a memory_view. This means the error could stem from how memory_view objects are being handled rather than their initial construction in the mbc6_device constructor. The compilation error mentions the line initializing m_flash_writable(0U), but the actual issue isn't with this initialization itself; the error message is somewhat misleading in that regard. It's more about how memory_view is utilized within your code.
Here are a couple of aspects and suggestions to consider based on the code you've provided:
Misleading Error Message
The error message points out the line with m_flash_writable(0U) which, in itself, does not involve memory_view. The actual issue likely resides elsewhere in how memory_view instances are used. Given the complex nature of template and macro expansions, sometimes error messages can point to the wrong location. The critical error message to focus on is the use of the deleted function memory_view::memory_view(const memory_view&).
memory_view Usage
You should check anywhere memory_view objects are passed to functions or returned from functions. Ensure you are not inadvertently causing a copy of a memory_view object. This could happen if a function designed to return a memory_view by value is called, or a memory_view object is passed by value to a function.
If there's a need to store references or pointers to memory_view objects in a way that outlives their initial scope, make sure to use references (memory_view&) or pointers (memory_view*), not values, to avoid copies.
Possible Areas to Investigate
The error could be indirectly related to how memory_view objects are managed in arrays or containers, or regarding their interactions with other parts of the MAME framework you're interfacing with. Investigate any such interaction points.
Double-check the logic around enabling and configuring memory views, particularly around dynamic configurations or reassignments, which might inadvertently trigger a copy operation.
General Advice
Review any recent changes made to the handling of memory_view objects.
Temporarily introduce verbose logging around operations on memory_view objects to trace their usage and identify where the copying might be attempted.
Considering the complexity of MAME's device and memory system, ensure that the usage patterns for memory_view follow the framework's expected practices, possibly by reviewing other devices' implementations for comparison.
Resolving this issue will likely require a careful review of where and how memory_view objects are utilized in your code, ensuring that all operations involving them adhere to move semantics or reference usage, rather than copying.