mapnik-org/mapnik — Issue #664: Compile error when including Cocoa/Cocoa.h on Mac OS X and using mapnik library
Author: artemp
Created: 2011-10-11 08:07:07+00:00
State: open
Labels: Core_Library

When attempting to compile the following code on Mac OS X

#include
#include
#include

int main (int argc, const char * argv[]) {
// insert code here...
CFShow(CFSTR("Hello, World!\n"));
return 0;
}

The following error is generated

In file included from /usr/local/include/mapnik/map.hpp:32,
from /Users/bob/Projects/foobar2/main.mm:3:
/usr/local/include/mapnik/enumeration.hpp:246:67: error: macro "verify" passed 2 arguments, but takes just 1
In file included from /usr/local/include/boost/ptr_container/detail/reversible_ptr_container.hpp:22,
from /usr/local/include/boost/ptr_container/ptr_sequence_adapter.hpp:20,
from /usr/local/include/boost/ptr_container/ptr_vector.hpp:20,
from /usr/local/include/mapnik/geometry.hpp:36,
from /usr/local/include/mapnik/feature.hpp:29,
from /usr/local/include/mapnik/filter.hpp:29,
from /usr/local/include/mapnik/rule.hpp:35,
from /usr/local/include/mapnik/feature_type_style.hpp:28,
from /usr/local/include/mapnik/map.hpp:33,
from /Users/bob/Projects/foobar2/main.mm:3:
/usr/local/include/boost/ptr_container/detail/static_move_ptr.hpp:154:50: error: macro "check" passed 2 arguments, but takes just 1
In file included from /usr/local/include/mapnik/map.hpp:32,
from /Users/bob/Projects/foobar2/main.mm:3:
/usr/local/include/mapnik/enumeration.hpp:246: error: function definition does not declare parameters
In file included from /usr/local/include/boost/ptr_container/detail/reversible_ptr_container.hpp:22,
from /usr/local/include/boost/ptr_container/ptr_sequence_adapter.hpp:20,
from /usr/local/include/boost/ptr_container/ptr_vector.hpp:20,
from /usr/local/include/mapnik/geometry.hpp:36,
from /usr/local/include/mapnik/feature.hpp:29,
from /usr/local/include/mapnik/filter.hpp:29,
from /usr/local/include/mapnik/rule.hpp:35,
from /usr/local/include/mapnik/feature_type_style.hpp:28,
from /usr/local/include/mapnik/map.hpp:33,
from /Users/bob/Projects/foobar2/main.mm:3:
/usr/local/include/boost/ptr_container/detail/static_move_ptr.hpp:154: error: function definition does not declare parameters
In file included from /usr/local/include/boost/pointee.hpp:16,
from /usr/local/include/boost/ptr_container/indirect_fun.hpp:24,
from /usr/local/include/boost/ptr_container/ptr_sequence_adapter.hpp:21,
from /usr/local/include/boost/ptr_container/ptr_vector.hpp:20,
from /usr/local/include/mapnik/geometry.hpp:36,
from /usr/local/include/mapnik/feature.hpp:29,
from /usr/local/include/mapnik/filter.hpp:29,
from /usr/local/include/mapnik/rule.hpp:35,
from /usr/local/include/mapnik/feature_type_style.hpp:28,
from /usr/local/include/mapnik/map.hpp:33,
from /Users/bob/Projects/foobar2/main.mm:3:
/usr/local/include/boost/detail/is_incrementable.hpp:73: error: expected unqualified-id before ')' token
/usr/local/include/boost/detail/is_incrementable.hpp:76: error: expected unqualified-id before ';' token
/usr/local/include/boost/detail/is_incrementable.hpp:84: error: expected unqualified-id before ')' token
/usr/local/include/boost/detail/is_incrementable.hpp:95: error: expected unqualified-id before ')' token

Work around taken from

http://www.opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AssertMacros.h

* Prior to Mac OS X 10.6 the macro names used in this file conflicted with some
* user code, including libraries in boost and the proposed C++ standards efforts,
* and there was no way for a client of this header to resolve this conflict. Because
* of this, most of the macros have been changed so that they are prefixed with
* __ and contain at least one capital letter, which should alleviate the current
* and future conflicts. However, to allow current sources to continue to compile,
* compatibility macros are defined at the end with the old names. A tops script
* at the end of this file will convert all of the old macro names used in a directory
* to the new names. Clients are recommended to migrate over to these new macros as
* they update their sources because a future release of Mac OS X will remove the
* old macro definitions ( without the double-underscore prefix ). Clients who
* want to compile without the old macro definitions can define the macro
* __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES to 0 before this file is
* included.