[Scummvm-devel] remove macro conflict in system headers

Федор fedor_qd at mail.ru
Thu Oct 31 19:39:16 CET 2013

 I added "#undef remove" in core.h after  #define TSAGE_CORE_H but also graphics.h got same fix.
Here compilation errors :
in core.h line 774 :
'class TsAGE::SynchronizedList<TsAGE::SceneObject*>' has no member named 'remove'

in scene.h line 124 :
'class TsAGE::SynchronizedList<TsAGE::GameHandler*>' has no member named 'remove'

in blueforce_scenes0.cpp lines 701 and 723, in blueforce_logic.cpp line 664 :
'class TsAGE::SceneItemList' has no member named 'remove'

Function remove() used in POSIX and linux to remove files and symbolic links. read here -  http://pubs.opengroup.org/onlinepubs/009695399/functions/remove.html
Scummvm uses this function itself in scummvm\backends\saves\default\default-saves.cpp.

Чацвер, 31 кастрычніка 2013, 14:32 +01:00 ад Johannes Schickel <lordhoto at gmail.com>:
>In fact, I'm not sure about this whole issue. I think plain C allows standard library functions to be defined as macros. I wonder how C++ handles this... i.e. is the name disallowed then? Should the compiler tread it specially?
>At any rate, a workaround for compilation would be to use the following:
>class A {
>        void (remove)(const char *);
>void (A::remove)(const char *) {
>i.e. use parenthesis around the remove use (this is somewhat suggested in the C standard when you declare library functions on your own or take their address IIRC).
>// Johannes
>On Thu, Oct 31, 2013 at 2:26 PM, Willem Jan Palenstijn  < wjp at usecode.org > wrote:
>>On Thu, Oct 31, 2013 at 02:21:56PM +0100, Johannes Schickel wrote:
>>> On Thu, Oct 31, 2013 at 1:55 PM, Willem Jan Palenstijn < wjp at usecode.org >wrote:
>>> > On Thu, Oct 31, 2013 at 12:35:28AM +0400, Икар wrote:
>>> > >
>>> > > When I building Tsage engine for symbian with GCCE 4.4.1 I got many
>>> > erros "macro `remove' used without args" because compilers think what
>>> > function :
>>> > > virtual void remove()=0
>>> > > and his virtual inheritance comes from macro definition
>>> > > #define remove(x) unlink(x)
>>> > > This define placed in sys/unistd.h
>>> > >
>>> > >  I try to  use '#undef remove' in core.h but it doesn't work.
>>> >
>>> > What do you mean by "doesn't work"?
>>> >
>>> > We use remove() in more places than just core.h, so I'm not sure what you
>>> > tried or how it doesn't work...
>>> >
>>> I think he talks about
>>>  https://github.com/scummvm/scummvm/commit08cd61acc249f93c2760fc45b45705c8836fbc7bwhich
>>> was reverted later. One possibly issue here could've been that you
>>> undefine such macros by simple "#undef remove" instead of "#undef
>>> remove(x)". Other issues might include core.h wasn't included in the
>>> offending files, core.h was included first and then #undef remove was
>>> before the actual #define.
>>The #undefine was at the very top of the header, so that does not sound like a
>>very safe or robust way to undefine something defined in a system header. It
>>doesn't surprise me at all that it doesn't compile after just thar one change.
>>-Willem Jan

С уважением, Федор Стрижнёв.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scummvm.org/pipermail/scummvm-devel/attachments/20131031/458b6090/attachment.html>

More information about the Scummvm-devel mailing list