devinacker / bsnes-plus

debug-oriented fork of bsnes
http://bsnes.revenant1.net
328 stars 92 forks source link

Build fails on Linux gcc 11.1.0 after recent commit #294

Closed nyanpasu64 closed 3 years ago

nyanpasu64 commented 3 years ago

Starting at commit d61924408ec946612827c79304cbc0b2d975f6ff "Allow for dumping an SPC file immediately via config option", I'm getting a build error:

g++ -std=gnu++0x -I. -I../common -Isnes -O3 -fomit-frame-pointer -DNDEBUG -Wno-switch -Wno-parentheses -DPROFILE_COMPATIBILITY -DDEBUGGER -Iobj `pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets` -fPIC -c ui-qt/main.cpp -o obj/compatibility/ui-main.o
In file included from snes/system/system.hpp:59,
                 from snes/snes.hpp:139,
                 from ui-qt/ui-base.hpp:12,
                 from ui-qt/main.cpp:1:
snes/config/config.hpp:17:10: error: declaration of ‘struct SNES::Configuration::SMP’ changes meaning of ‘SMP’ [-fpermissive]
   17 |   struct SMP {
      |          ^~~
In file included from snes/profile-compatibility.hpp:6,
                 from snes/snes.hpp:134,
                 from ui-qt/ui-base.hpp:12,
                 from ui-qt/main.cpp:1:
snes/smp/smp.hpp:1:7: note: ‘SMP’ declared here as ‘class SNES::SMP’
    1 | class SMP : public Processor, public SMPcore, public MMIO {
      |       ^~~
make: *** [ui-qt/Makefile:76: obj/compatibility/ui-main.o] Error 1

The error persists if I remove all lines from the diff except SMP::SPCSavePolicy spc_save_policy; and enum class SPCSavePolicy : unsigned { OnNextNote = 0, Immediately = 1 };, but goes away if I remove the first but keep the second.

I don't know how this commit could've caused this error. I don't like the build system of this project, constructed around non-self-contained headers and source files, and it makes it hard to tell what files belong to what namespaces and classes, to figure out the issue. I was unable to find much information about this error online, and https://stackoverflow.com/questions/15537023 is talking about a method rather than a struct or class.

A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S.

What's "its" context? What's the completed scope of S?

https://stackoverflow.com/questions/16452922 seems helpful-ish.

black-sliver commented 3 years ago

Thanks for figuring out the commit that introduced the problem, made it easy to find :) Let's hope the fix gets merged soon.

And sorry for the noise, i pushed the fix to my fork, then fixed a typo, then cherry-picked it.