ONI_EXPORT_DRIVER macro uses undeclared XN_NEW and XN_DELETE
In OniDriverAPI.h, the ONI_EXPORT_DRIVER macro references the XN_NEW and XN_DELETE macros, but these are not declared at that point. This only shows up if you call ONI_EXPORT_DRIVER without including XnLib, which I am trying to do.
I replaced the XN_* macros with simple new and delete and it works fine for me. I'm constantly confused as to the necessity of many parts of XnLib... much of it seems like an exercise in unnecessary abstraction now that the core is in C++.
This is still a problem in OpenNI 2.2 Alpha from http://www.openni.org/openni-sdk/. When I try to compile a driver against Include/Driver/OniDriverAPI.h, I get
../src/DeviceDriver.cpp: In function 'void oniDriverCreate(OniDriverServices*)':
../src/DeviceDriver.cpp:271:1: error: expected primary-expression before ',' token
../src/DeviceDriver.cpp:271:1: error: 'XN_NEW' was not declared in this scope
../src/DeviceDriver.cpp: In function 'void oniDriverDestroy()':
../src/DeviceDriver.cpp:271:1: error: 'XN_DELETE' was not declared in this scope
Line 271 contains my call to the ONI_EXPORT_DRIVER macro.
I'm guessing no one else is writing OpenNI2 drivers so this is low priority. In any case, the workaround is simple:
// macros defined in XnLib (not included) - workaround
#define XN_NEW(type, arg...) new type(arg)
#define XN_DELETE(p) delete(p)
ONI_EXPORT_DRIVER(FreenectDriver::Driver);
#undef XN_NEW
#undef XN_DELETE