How to detect sierra with macro in 10.12 - macos

i want to use #ifdef __MAC_10_12 to detect that the current os version is 10.12, but the header file Availability.h doesn't have this define, the highest version for that file is #define __MAC_10_11_4 101104
So how can i do this right now?

Related

macOS SDK11 / ARM64: statfs64 / f_mntonname

I am using the function statfs64 to obtain the mount point from a path on macOS via property f_mntonname.
This works fine when building against the SDK 10.x for the architecture x86_64.
However, when building for arm64 (and SDK 11), the method is not available.
I can use statfs as fallback which seems to be available, but this has limits to the path length.
I know there is the NSFileManager-API (attributesOfFileSystemForPath), but unfortunately there is no property for the mount path.
Does anyone know how to to this on the new SDK/Platform?
Thank you and regards,
Dominik
statfs64 and fstatfs64 have been deprecated since macOS 10.6 in favour of "versioned symbols".
If you're building for macOS 10.6 or higher, simply switch to statfs and fstatfs, and add this at the top of your source files (before the includes):
#define _DARWIN_USE_64_BIT_INODE
Or add a compiler flag, if changing many source files is too tedious:
-D_DARWIN_USE_64_BIT_INODE
For arm64 targets, this is already set, so it has no effect.
For x86_64 targets, this causes the linker to emit a dependency on _statfs$INODE64 (which is equivalent to _statfs64) rather than _statfs.
If your x86_64 slice does indeed need to support macOS 10.5, then you'll have to resort to some preprocessing:
#define _DARWIN_USE_64_BIT_INODE
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1060
#define STATFS statfs64
#define FSTATFS fstatfs64
#else
#define STATFS statfs
#define FSTATFS fstatfs
#endif
And if you need to support macOS 10.4 or lower, you're out of luck anyway because there is no 64-bit inode support back there.

include GLUT in qt project with cmake

I'm trying to do a cmake project with opengl and qt.
this is the cmake where I include opengl:
# opengl
set(QT_USE_QTOPENGL TRUE)
find_package(OpenGL REQUIRED)
find_package(GLUT REQUIRED)
include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} )
set(OPENGL_LIBS ${OPENGL_LIBRARIES} ${GLUT_LIBRARY})
And it found them, this is a part of cmake output:
-- Found OpenGL: /System/Library/Frameworks/OpenGL.framework
-- Found GLUT: -framework GLUT
And I can include OpenGL with this:
#include <QtOpenGL>
with this it finds correctly gl* glGetString(GL_VENDOR) or glGetString(GL_VERSION) and they works.
BUT I'm not able to include GLUT includes.
I'm on Mac OSX 10.8.4, Qt 4.8, QtCreator 2.7.1 and Opengl 2.1
Please note that the same cmake file under Ubuntu 12.04 let me include GL/gl.h and GL/glut.h correctly.
BUT I'm not able to include GLUT includes.
Why would you want to use GLUT when you're already using Qt?
GLUT is a framework for window creation and event loop processing.
Qt is a framework for window creation and event loop processing.
You can't (well, should not) have two framework within the same program doing the exact same thing (unless you're interested in seeing them fighting some battle over the same resources).
On OSX you need to include GLUT/glut.h, so write something like that in your code:
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

Intel C++ compiler and cannot open stdarg.h on OS X

OS X 10.6.8, XCode 3.2.6, Base SDK 10.5, Intel Compiler 11.1
I am getting a weird message when I try to compile that says:
catastrophic error: could not open source file "stdarg.h"
I am using a PCH, I did find: Xcode Intel compiler icc cannot find #include <algorithm>
which is a similar issue and I think that the source file type is set to .c.c instead of .c
From what I can see stdarg.h is:
/* This file is public domain. */
/* GCC uses its own copy of this header */
#if defined(__GNUC__)
#include_next <stdarg.h>
#elif defined(__MWERKS__)
#include "mw_stdarg.h"
#else
#error "This header only supports __MWERKS__."
#endif
so must be GNUC is defined, obviously.
Can anyone help me figure out how to better compile since this works without changes in GCC 4.0? Is there a global way one might have XCode re-evaluate the source file type to not be .c.c or .cpp.cpp I am not even sure how this would happen.
Also, is there a #define that I can check to see if the Intel compilers are being used to make special cases if I need to?
I looked at a few of the files referenced in the build results and looking at the source file type in XCode it says source.c.c and I think if I change that to source.c that compiler error goes away.

Xcode Intel compiler icc cannot find #include <algorithm>

Hi I'm trying to compile a gcc based code on Xcode with the icc compiler (11.1.088)
but i have the following error:
catastrophic error: could not open source file "algorithm"
After looking to this file, it is located in the gcc include directory, but i get hundreds of errors...
Does anyone have suggestions ?
Thanks.
I was having a really stubborn error very similar to this question but with a different solution.
Algorithm: No such file or directory
My solution:
#ifdef __cplusplus
#include <algorithm>
#endif
I had the #include in a prefix header file (such as the .pch file Xcode gives you in a new project) which was causing it to be included in an Objective-C file, and apparently algorithm is C++ only. Either make sure all your Objective-C files are Objective-C++ (.mm) or add that directive to make sure it doesn't get included in those files.
What do you have set as your base SDK ? And what version of Xcode ?
FWIW I just tried a test with Xcode 3.2.3 and ICC 11.1 (under OS X 10.6 of course) - created a new C++ console application using the standard Xcode template, added #include <algorithm> to main.cc, switched from the default gcc 4.2 to ICC, and it compiles and runs without warnings or errors. The base SDK is the system default (10.6).
It may just be that you have a bad installation of Xcode and/or ICC, or perhaps you have changed a project setting such as base SDK, and this is causing problems.
This problem occurred on my machine, while developing an iOS app.
Xcode Version 4.6.3 (4H1503) & iOS version 6.0
I'm using AppCode for development and the IDE added (by accident) the following import statement:
#import <c++/4.2.1/ext/algorithm>
I met this error too, I just forget to change the source from .m to .mm. so, if adjust C++ complier cannot work, try to change the source file.

How do I tell on Mac OS X if I have the Carbon or Cocoa version of Qt installed?

I installed the QtSDK, but I can't find any documentation anywhere that specifies whether it uses the Cocoa or Carbon version. Can I find out which got installed? If not, is it safe to install the Cocoa version from the Library only dmg? Qt version is 4.6.3, system version is 10.6.4.
When using qmake, the following should work:
There is QT_MAC_USE_COCOA, so a simple test would be:
...
#ifdef QT_MAC_USE_COCOA
std::cout << "Cocoa!" << std::endl;
#else
std::cout << "Carbon!" << std::endl;
#endif
I don't have a Mac nearby to test put checking the type of QPaintEngine might do the trick. I believe Carbon would return QPaintEngine::QuickDraw and Cocoa QPaintEngine::CoreGraphics but I'm not sure.
To quote:
The current binary for Qt is built in two flavors, 32-bit Carbon and full universal Cocoa (32-bit and 64-bit). If you want a different setup for Qt will use, you must build from scratch. Carbon or Cocoa is chosen when configuring the package for building. The configure process selects Carbon by default, to specify Cocoa use the -cocoa flag. configure for a 64-bit architecture using one of the -arch flags
10.4 Tiger Carbon 32 PPC/Intel Yes
10.5 Leopard Carbon 32 PPC/Intel Yes
10.5 Leopard Cocoa 32/64 PPC/Intel Yes
10.6 Snow Leopard Cocoa/Carbon 32 PPC/Intel Yes
10.6 Snow Leopard Cocoa 64 Intel Yes
More information is available on http://doc.trolltech.com/4.6/developing-on-mac.html#carbon-or-cocoa.

Resources