[ scummvm-Bugs-2971226 ] Compilation error - SWAP undeclared in algorithm.h

SourceForge.net noreply at sourceforge.net
Tue Mar 16 13:05:08 CET 2010


Bugs item #2971226, was opened at 2010-03-16 14:05
Message generated for change (Tracker Item Submitted) made by salty-horse
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=418820&aid=2971226&group_id=37116

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Ori Avtalion (salty-horse)
Assigned to: Nobody/Anonymous (nobody)
Summary: Compilation error - SWAP undeclared in algorithm.h

Initial Comment:
While trying tom compile from SVN with clang, I encountered the following error:

In file included from engines/scumm/detection.cpp:26:
In file included from ./base/plugins.h:31:
In file included from ./common/util.h:30:
In file included from ./common/str.h:29:
In file included from ./common/array.h:29:
./common/algorithm.h:182:2: error: use of undeclared identifier 'SWAP'

algorithm.h uses SWAP without including util.h.

The reason the code compiles in gcc is that (after preprocessing) engines/scumm/detection.cpp includes common/util.h AFTER including common/algorithm.h. Since SWAP depends on the template arguments of sortPartition, gcc only instantiates it (and lookups its symbols) at the end of the translation unit.

See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29131 for details. There is an open issue about whether this is defined behavior with the C++ standards committee.

In any case, this is an ugly edge-case. However, it cannot easily be fixed by including common/util.h in common/algorithm.h. This causes a circular dependency between util.h -> str.h -> array.h -> algorithm.h -> util.h

A possible solution is to not use SWAP in algorithm.h.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=418820&aid=2971226&group_id=37116




More information about the Scummvm-tracker mailing list