Reputation: 3045
The TARGET_IPHONE_SIMULATOR macro does not work in the C++ source I added to the project. Though it should be noted that the code runs if I simply change out the macro with a 1 or a 0.
So here's the setup. I've been converting the files from : https://code.google.com/p/ld48jovoc/source/browse/util/tweakval/?r=13 to work with the iOS application I'm making in XCode.
Everything is pretty much the same except for the header.
#ifndef TWEAKVAL_H
#define TWEAKVAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
// Do only in debug builds on simulator, this does NOT work on iOS device
#if TARGET_IPHONE_SIMULATOR // replace with 1 or zero to make it work
# define TV_USE_TWEAKVAL 1
#else
# define TV_USE_TWEAKVAL 0
#endif
//
// See the thread referenced above for idea of how to implement
// this without the __COUNTER__ macro.
// If we are in a build modethat wants tweakval, and the compiler
// supports it, use it
#if TV_USE_TWEAKVAL
# define _TV(Val) _TweakValue( __FILE__, __COUNTER__, Val )
//float _TweakValue( const char *file, size_t counter, float origVal );
int _TweakValue( const char *file, size_t counter, int origVal );
void ReloadChangedTweakableValues();
#else
// don't use it
# define _TV(Val) Val
# define ReloadChangedTweakableValues()
#endif
#ifdef __cplusplus
} // extern "C"
#endif
#endif
the cpp file is nearly identical except the whole thing is wrapped in #if TV_USE_TWEAKVAL.
Now I could set this macro manually, via code or in the build settings but I'd prefer to get this thing to automatically enable/disable via detecting the preprocessor command. My guess is that macro is not getting detected when it links the tweakval source code and I don't know what build settings I need to change to fix this issue.
Thanks.
Upvotes: 0
Views: 767
Reputation: 8012
TARGET_IPHONE_SIMULATOR
comes from TargetConditionals.h
. You need to #include
that file. Presumably your other code gets it indirectly via some other path like Cocoa/Cocoa.h
.
Upvotes: 2