AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Solved MM:S plugin fails to compile due to stdlib-related error on newer toolchains (https://forums.alliedmods.net/showthread.php?t=332701)

nosoop 05-28-2021 00:06

MM:S plugin fails to compile due to stdlib-related error on newer toolchains
 
I'm trying to compile my fork of RCBot2 (a hybrid MM:S plugin and SourceMod extension), and it reports the following error message on the current Debian (Buster) release using Clang:

Code:

In file included from /home/user/alliedmodders/rcbot2/utils/RCBot2_meta/bot_plugin_meta.cpp:40:
In file included from /home/user/alliedmodders/rcbot2/utils/RCBot2_meta/bot.h:68:
In file included from /home/user/alliedmodders/rcbot2/utils/RCBot2_meta/bot_utility.h:37:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/vector:60:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_algobase.h:64:
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_pair.h:428:13: error: no member named 'swap' in namespace 'std'
        using std::swap;
              ~~~~~^

A similar error among others is displayed on GCC:

Code:

In file included from /usr/include/c++/8/bits/stl_algobase.h:64,
                from /usr/include/c++/8/vector:60,
                from /home/user/alliedmodders/rcbot2/utils/RCBot2_meta/bot_utility.h:37,
                from /home/user/alliedmodders/rcbot2/utils/RCBot2_meta/bot.h:68,
                from /home/user/alliedmodders/rcbot2/utils/RCBot2_meta/bot_plugin_meta.cpp:40:
/usr/include/c++/8/bits/stl_pair.h: In member function ‘void std::pair<_T1, _T2>::swap(std::pair<_T1, _T2>&)’:
/usr/include/c++/8/bits/stl_pair.h:428:13: error: ‘std::swap’ has not been declared
  using std::swap;
            ^~~~

Full error message is available in this issue. It's known to compile against the older Debian 8 and Ubuntu 16.04 without any changes. Google comes up with no results on this particular error, and similar issues don't seem to fit this problem.

Any ideas of where to go from here? Very lost since the compile error appears to happen within the standard library. Compiling a short C++ file using clang++ with the algorithm and vector includes does work no problem.

Would prefer to stick to c++11.

nosoop 05-28-2021 00:32

Re: MM:S plugin fails to compile due to stdlib-related error on newer toolchains
 
Ah, that's silly. Commenting out every instance of

Code:

#define swap V_swap
and

Code:

#undef swap
seems to work. This effectively reverts one of my previous commits in my fork which intended to avoid conflicts with libstdc++ at the time. (It predates the corresponding commit to fix this in DoD:S.)

Not sure why the redefinition doesn't show up in the compiler errors, but regardless, this is solved.


All times are GMT -4. The time now is 14:24.

Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.