New issue 35 by jdswinb...@gmail.com: Missing header file on MacOS X 10.6
http://code.google.com/p/casacore/issues/detail?id=35
r21022 added a check for defined(__MAC_10_6) at line 40 of
casa/IO/TapeIO.cc.
__MAC_10_6 is defined in /usr/include/Availability.h, which isn't being
included. It's therefore undefined, so the system proceeds to try to
include <sys/mtio.h>, which doesn't exist on OS X 10.6, and therefore fails.
The attached patch fixes the issue.
Attachments:
patch-mtio.diff 387 bytes
(A more careful check demonstrates that r21022 didn't actually add the
check for __MAC_10_6, it just caused me to notice it!)
The patch introduces a compile error on older OS-X systems that do not have
Availability.h.
I wonder if the test on !defined(__AVAILABILITY__) should have the !
removed. I assume that this variable is only defined in Availability.h is
available.
Cheers,
Ger
Hi Ger,
Yes, apologies -- that patch was just wrong. Sorry. The problem is actually
more complex than I previously understood.
__MAC_10_6 is defined in Availability.h: so far as I can see, it will
therefore never be defined in the current casacore trunk, so the check in
casa/IO/TapeIO.cc is useless.
However, even including Availability.h isn't enough: it also defines
__MAC_10_6 on OSX 10.5. Therefore, checking for __MAC_10_6 as a guide to
whether the system is running OSX 10.6 is useless.
I attach an updated patch, which looks at the value of
MAC_OS_X_VERSION_MAX_ALLOWED, defined in AvailabilityMacros.h. This
reflects the version of the SDK being used, which is, I think, what's
required; it also means that one can use a different SDK to target a
different version of OSX from the one currently running.
Unfortunately, I don't have a Mac running an earlier version of OSX which I
can easily check this patch on. Google suggests that the
AvailabilityMacros.h file was included with OSX as far back as 10.2,
though, so I hope this isn't a problem.
Attachments:
patch-mtio.diff 589 bytes
Hi Ger,
Yes, apologies -- that patch was just wrong. Sorry. The problem is actually
more complex than I'd previously grasped. My understanding now is:
__MAC_10_6 is defined in /usr/include/Availability.h: so far as I can see,
that's not included by anything in casacore, so it will therefore never be
defined. The check in casa/IO/TapeIO.cc is useless.
However, even if Availability.h is included, the check doesn't seem to do
what's required. Availability.h on OSX 10.5 defines __MAC_10_6, so relying
on it as a guide to the version being used is a mistake.
I think the solution is to check the value of MAC_OS_X_VERSION_MAX_ALLOWED,
defined in /usr/include/AvailabilityMacros.h. This should correspond to the
version of the SDK being used, which is really the relevant issue (the OS X
10.6 SDK doesn't include mtio.h, but compiling for earlier versions using
earlier SDKs on 10.6 should work).
I attach an updated patch, which, I think(!), does the right thing.
Unfortunately, I don't have a Mac running an earlier version of OSX which I
can easily check this patch on. Google suggests that the
AvailabilityMacros.h file was included with OSX as far back as 10.2,
though, so I hope it will work.
Cheers,
John
Attachments:
patch-mtio.diff 589 bytes
John,
I have an older OS-X. It also set NOTAPE because the 10_6 variable is
undefined there. So I changed it to the following:
// MAC_OS_X_VERSION_MAX_ALLOWED reflects the version of the SDK being used
# include <AvailabilityMacros.h>
# if defined(MAC_OS_X_VERSION_10_6)
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
# define CASA_NOTAPE 1
# endif
# endif
#
Hi Ger,
Agreed, that looks fine to me.
Comment #7 on issue 35 by gervandi...@gmail.com: Missing header file on
(No comment was entered for this change.)