URL:
  <http://gna.org/bugs/?17150>

                 Summary: gui::menu::nitems() conflicts with nitems() macro
of OpenBSD sys/param.h
                 Project: Battle for Wesnoth
            Submitted by: kernigh
            Submitted on: Friday 11/26/2010 at 18:31
                Category: Bug
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: User Interface
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 1.8.5
        Operating System: OpenBSD 4.8

    _______________________________________________________

Details:

OpenBSD + CMake fails to compile Wesnoth 1.8.5.

One of the reasons is that g++ errors about 'sizeof' wherever something
mentions the gui::menu::nitems() function defined at src/widgets/menu.hpp.
There seems to be a conflict with this nitems() macro at
/usr/include/sys/param.h:


#define nitems(_a)      (sizeof((_a)) / sizeof((_a)[0]))


I am not sure how Wesnoth pulls sys/param.h, but I am sure that some nitems()
macro causes the problem. The compiler error typically happens at
src/widgets/menu.hpp:189, where Wesnoth defines nitems(), but the error can
also happen at files that call nitems().

To work around this problem, and allow Wesnoth to compile, I added an '#undef
nitems' at two places: src/widgets/menu.hpp:189 and
src/multiplayer_create.cpp:435. (The second file seems to pull sys/param.h
_after_ src/widgets/menu.hpp, so it needs the '#undef nitems' at a different
place.) The attached diff shows where I added '#undef nitems'.

One fix might be to rename the nitems() function to some other name. Another
fix might be to find exactly where Wesnoth pulls sys/param.h, and add '#undef
nitems' to that place, with a comment that the line is a workaround for
OpenBSD. I suspect that Wesnoth includes some header file (perhaps a boost
header?) which includes the DNS resolver (<netdb.h> or <resolv.h>). With
OpenBSD, both netdb.h and resolv.h include sys/param.h.

My system is OpenBSD 4.8 (including g++ 4.2.1) and has these packages:
* boost-1.42.0p2
* sdl-1.2.13p14
* sdl-net-1.2.7p1




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Friday 11/26/2010 at 18:31  Name: undef-nitems.diff  Size: 709B   By:
kernigh
where I added '#undef nitems' to Wesnoth 1.8.5
<http://gna.org/bugs/download.php?file_id=11388>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?17150>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to