Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-08-06· OpenAIAi2 WildChat-4.8M (AI2)

I have the following compile error: GCC 10.3.0 detected Compiling…

  1. User

    I have the following compile error:

    GCC 10.3.0 detected Compiling src/mame/igs/igs_m027xa.cpp... In file included from d:/mingw/mingw64-w32/mingw32/include/c++/10.3.0/cstdlib:75, from d:/mingw/mingw64-w32/mingw32/include/c++/10.3.0/stdlib.h:36, from d:/mingw/mingw64-w32/mingw32/i686-w64-mingw32/include/assert.h:17, from d:/mingw/mingw64-w32/mingw32/include/c++/10.3.0/cassert:44, from D:/mingw/mame/src/lib/util/corealloc.h:16, from D:/mingw/mame/src/emu/emucore.h:26, from D:/mingw/mame/src/emu/emu.h:33, from ../../../../../src/mame/igs/igs_m027xa.cpp:11: ../../../../../src/mame/igs/igs_m027xa.cpp:68:6: error: expected unqualified-id before '==' token 68 | u32 rand_r() | ^~~~~~ ../../../../../src/mame/igs/igs_m027xa.cpp:68:6: error: expected ')' before '==' token In file included from D:/mingw/mame/src/emu/emu.h:33, from ../../../../../src/mame/igs/igs_m027xa.cpp:11: ../../../../../src/mame/igs/igs_m027xa.cpp: In member function 'void {anonymous}::igs_m027xa_state::igs_mahjong_map(address_map&)': ../../../../../src/mame/igs/igs_m027xa.cpp:106:55: error: 'rand_r' is not a member of '{anonymous}::igs_m027xa_state' 106 | map(0x4000000c, 0x4000000f).r(FUNC(igs_m027xa_state::rand_r)); | ^~~~~~ D:/mingw/mame/src/emu/emucore.h:211:18: note: in definition of macro 'FUNC' 211 | #define FUNC(x) &x, #x | ^ igs.make:573: recipe for target '../../../../mingw-gcc/obj/x32/Release/src/mame/igs/igs_m027xa.o' failed make[2]: *** [../../../../mingw-gcc/obj/x32/Release/src/mame/igs/igs_m027xa.o] Error 1 makefile:226: recipe for target 'igs' failed make[1]: *** [igs] Error 2 makefile:1147: recipe for target 'windows_x86' failed make: *** [windows_x86] Error 2

    The sourcefile igs_m027xa.cpp:

    // license:BSD-3-Clause // copyright-holders: Xing Xing, David Haywood

    /*

    IGS ARM7 (IGS027A) based Mahjong / Gambling platform(s) with XA sub-cpu These games use the IGS027A processor.

    */

    #include "emu.h"

    #include "igs017_igs031.h" #include "pgmcrypt.h"

    #include "cpu/arm7/arm7.h" #include "cpu/arm7/arm7core.h" #include "cpu/xa/xa.h"

    #include "machine/i8255.h" #include "machine/nvram.h"

    #include "screen.h"

    namespace {

    class igs_m027xa_state : public driver_device { public: igs_m027xa_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_igs_mainram(*this, "igs_mainram"), m_maincpu(*this, "maincpu"), m_xa(*this, "xa"), m_ppi(*this, "ppi8255"), m_igs017_igs031(*this, "igs017_igs031"), m_screen(*this, "screen") { }

    void igs_mahjong_xa(machine_config &config);
    
    void init_crzybugs();
    void init_crzybugsj();
    void init_hauntedh();
    void init_tripfev();
    void init_wldfruit();
    

    protected: virtual void machine_start() override; virtual void video_start() override;

    private: optional_shared_ptr m_igs_mainram; required_device<cpu_device> m_maincpu; required_device<mx10exa_cpu_device> m_xa; required_device<i8255_device> m_ppi; required_device<igs017_igs031_device> m_igs017_igs031; required_device<screen_device> m_screen;

    void vblank_irq(int state);
    
    void pgm_create_dummy_internal_arm_region();
    void igs_mahjong_map(address_map &map);
    
    void igs_70000100_w(u32 data);
    u32 m_igs_70000100 = 0;
    
    u32 rand_r()
    {
    	return machine().rand();
    }
    

    };

    void igs_m027xa_state::machine_start() { save_item(NAME(m_igs_70000100)); }

    void igs_m027xa_state::video_start() { m_igs017_igs031->video_start(); }

    void igs_m027xa_state::igs_70000100_w(u32 data) { m_igs_70000100 = data; }

    . . .

  2. Assistant

    The error you're encountering is due to the function rand_r conflicting with a POSIX function of the same name. GCC expects that standard function here, which can lead to errors when your function name matches a standard one directly or indirectly included through headers.

    To resolve this issue, you can rename your rand_r function to something unique, which will not conflict with other functions in the standard library or other libraries. Here's how you could rename your function to, say, generate_random:

    // Original function
    // u32 rand_r()
    // {
    //     return machine().rand();
    // }
    
    // Renamed function
    u32 generate_random()
    {
        return machine().rand();
    }
    
    void igs_m027xa_state::igs_mahjong_map(address_map &map)
    {
        // Original line
        // map(0x4000000c, 0x4000000f).r(FUNC(igs_m027xa_state::rand_r));
    
        // Updated line using the new function name
        map(0x4000000c, 0x4000000f).r(FUNC(igs_m027xa_state::generate_random));
    }
    

    Make sure to update any other occurrences of rand_r() throughout your code with generate_random() as needed. This will prevent conflicts with the standard library function and should resolve the compile error you're encountering.

  3. User

    Many thanks!

  4. Assistant

    You're welcome! If you have any more questions or need further assistance, feel free to ask. Happy coding!