Posts Tagged ‘iPhone’


Testing for presence of Apple platform in C/C++/ObjC code

Monday, August 9th, 2010
Are we running on an Apple platform?
#ifdef __APPLE__
#endif
Prerequisite for other tests
#ifdef __APPLE__
// let Apple define 
// various TARGET_OS_ 
// constants
#include  
#else
// not on Apple platform
#define TARGET_OS_MAC 0
#define TARGET_OS_IPHONE 0
#endif
Are we running on Mac OS X?
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
….
#endif
Are we running on an iOS device?
#if TARGET_OS_IPHONE
….
#endif
// updated on Oct13 2010, previous method was flawed. sorry everyone!

iPhone development: Bits/c++config.h: No such file or directory

Tuesday, April 27th, 2010

Developing for iPhone with some C++ code? Suddenly getting this error after installing a beta SDK?

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h:65:0 Bits/c++config.h: No such file or directory in /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/include/c++/4.2.1/bits/stl_algobase.h

Note the bolded folder. Change into it and make a symlink from arm-apple-darwin9 to arm-apple-darwin10. Please note that Apple has fixed this already at one upgrade of beta SDK (I had this error before too, but I still didn’t get 4.0 beta 2 so I didn’t check) so it’s reasonable to assume they will do this again.

cd Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.2.sdk/usr/include/c++/4.2.1/
ln -s arm-apple-darwin9 arm-apple-darwin10

PS I don’t think posting this violates any NDA. Especially since origin for this solution is also public.

iPhone does not appear in iPhoto

Wednesday, March 3rd, 2010

So, ordinarily, iPhone is supposed to appear in your iPhoto list, as pictured. But what if that doesn’t happen, and you’ve tried everything: erasing iPhoto settings, playing with iTunes preferences… everything, in fact, except erasing your iPhone’s valuable data? How to sync photos into iPhoto again; that is, how to get your iPhone to introduce itself as a camera once again?

As strange as it may sound, this is caused by you downloading picture attachments or choosing Save image in mobile Safari. So just go and mail yourself every photo from Camera Roll that was not created with iPhone’s own Camera, and then delete them.

That’s right, just go right ahead and delete all the photos you downloaded from your iPhone’s Camera Roll. This’ll restore your access. This has worked on my iPhone 2G with OS 3.1.2.

Well, if it doesn’t help you, you could also try something else from this thread on MacRumors forums.

Warfare Inc for iPhone is on discount

Saturday, February 27th, 2010

Get the most advanced PalmOS game, now ported to iPhone!
App Store
It currently costs only $0.99 vs $4.99. It’s a magnificent, magnificent RTS. I haven’t tried it on iPhone yet, but on Palm, it rocked.

Note: I have no connection to developer whatsoever. I just like old PalmOS and software written for it. And most importantly, this is not an ad, it’s just my unpaid, private invitation to you to try the game out :-)

My iPhone’s GSM started working :-D

Tuesday, February 9th, 2010

This year I celebrated birthday with friends for the first time ever. And they gave me a fancy-schmancy gift: an iPhone 2G! Until today GSM didn’t work (apparently due to … “enabling” some stuff). After downloading … “fixes”, it started working. BootNeuter is the keyword. I “wouldn’t” know for what, though :-)

Well, I just wanted you guys to know :-)

Fixing “warning: missing sentinel in function call”

Saturday, August 22nd, 2009

I got it for the folowing line:

execl(“/bin/sh”, “sh”, “-c”, sessioncommand.c_str(), 0);

Quite easy to fix:

execl(“/bin/sh”, “sh”, “-c”, sessioncommand.c_str(), (char*)0);

—————————————–

Alright. Since I’m getting “lots” of hits on this, let’s see if we can improve this post. (June 28th 2010, more examples added July 22nd 2010)

Generally, you’re missing a sentinel if you don’t add a “NULL” in C/C++, or a “nil” in Objective-C. In above example in C, I presume the compiler did not notice the zero (a valid sentinel) and threw a warning. That’s what this post was mostly about.

However, it could also happen if you really did forget to add the sentinel. What is the purpose of this “sentinel”? When iterating through a varlist**, the function needs to know where to stop. In printf() and scanf(), the format string specifies this number of arguments. Functions could also accept the number of arguments as one of the arguments. Third option is this — specifying a sentinel, such as NULL or nil, as something that will stop further iteration.

Examples of sentinels in C:

execl(“/bin/sh”, “sh”, “-c”, sessioncommand.c_str(), NULL);

and in Objective-C:





NSArray *names = [NSArray arrayWithObjects: @"Ivan", @"Ana", @"Marko", @"Petar", nil];

Did you like this explanation? Click below to give feedback via rating, or post a comment. Login not needed for rating, and probably not for commenting either. :-)

** Iterating through a varlist - which is how you iterate through arguments in variadic functions, those with variable number of arguments