Opened 11 years ago

Closed 11 years ago

Last modified 5 years ago

#6413 closed defect

BUILD: Fix build with --enable-c++11 on FreeBSD

Reported by: (none) Owned by: digitall
Priority: normal Component: Ports
Version: Keywords: build
Cc: Game:

Description

On FreeBSD, the definition of NULL depends on the version of the C++ standard used. When building C++03 code, NULL is defined to 0. When building C++11 code, it is defined to nullptr instead. This behaviour is allowed by the standard.

ScummVM has a couple pieces of code, where a null pointer is being cast to an integer type. When building ScummVM as C++03, this works, as it simply yields integer 0. In C++11 mode, this causes the build to fail.

Furthermore, there are several pieces of code in ScummVM that use anonymous structs/unions. This causes Clang to print compiler warnings, as anonymous structs/unions are not part of the standard. This is not addressed by this patch.

Ticket imported from: #3615056. Ticket imported from: bugs/6413.

Attachments (1)

patch-engines__tinsel__scene.cpp (393 bytes ) - added by SF/*anonymous 11 years ago.

Download all attachments as: .zip

Change History (5)

by SF/*anonymous, 11 years ago

comment:1 by (none), 11 years ago

I can't find the link to upload a second file, so here's the second patch

--- ./engines/tony/mpal/mpal.cpp.orig 2013-05-26 22:21:48.000000000 +0200 +++ ./engines/tony/mpal/mpal.cpp 2013-09-27 16:52:35.138414956 +0200 @@ -409,7 +409,7 @@ sl[k++] = dialog->_choice[i]._select[j]._dwData; }

- sl[k] = (uint32)NULL; + sl[k] = 0; return sl; }

@@ -436,7 +436,7 @@ } }

- il[j] = (uint32)NULL; + il[j] = 0; return il; }

@@ -831,7 +831,7 @@

if (_ctx->k == 0) // We can remove this item from the list - _ctx->il[_ctx->i] = (uint32)NULL; + _ctx->il[_ctx->i] = 0; else _ctx->nRealItems++; }

comment:2 by digitall, 11 years ago

Unamed Google User: Thank you for your two patches. Have reviewed and these are uncontroversial, so have merged them to the development master. Closing this bug as fixed.

If you wish us to fix the anonymous structs/unions, please open a new bug and attach either a patch for this or at least a copy of the compiler standard error output from this listing all of the instances... Thanks.

comment:3 by digitall, 11 years ago

Owner: set to digitall
Status: newclosed
Summary: Fix build with --enable-c++11 on FreeBSDBUILD: Fix build with --enable-c++11 on FreeBSD

comment:4 by digitall, 5 years ago

Component: Ports
Note: See TracTickets for help on using tickets.