iPhone:- Using inline function:- shows error when using Debug configuration
when i am using Simulator-> release configuration the code is running ok. but if i use Simulator -> Debug configuration is giving me following error
Undefined symbols:
"_AGTileInfoEqualToAGTile", referenced from:
-[TiledScrollView loadTileAtPoint:] in TiledScrollView.o
"_AGTileInfoMake", referenced from:
-[TiledScrollView loadTilesIfNeeded] in TiledScrollView.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Here is the code
typedef struct
{
NSString *dataSet;
NSInteger level;
NSInteger x;
NSInteger y;
}AGTi开发者_开发技巧leInfo;
/* Make a AGTileInfo */
inline AGTileInfo AGTileInfoMake(NSString *dataSet, NSInteger level, NSInteger x, NSInteger y);
inline AGTileInfo
AGTileInfoMake(NSString *dataSet, NSInteger level, NSInteger x, NSInteger y)
{
AGTileInfo tInfo; tInfo.dataSet = dataSet; tInfo.level = level; tInfo.x = x; tInfo.y = y; return tInfo;
}
inline bool AGTileInfoEqualToAGTile(AGTileInfo info1, AGTileInfo info2);
inline bool
AGTileInfoEqualToAGTile(AGTileInfo info1, AGTileInfo info2)
{
return [info1.dataSet isEqualToString:info2.dataSet] && (info1.level==info2.level) && (info1.x == info2.x) && (info1.y == info2.y) ;
}
Thanks in advance.
Have you tried compiling without the "inline" clause?
Have a look at this: Objective C: Inline function - symbol not found
Thanks to xj1200. His link was really helpful. All i did was add "static" modifier before inline. Here is the new code and it is working fine.
static inline AGTileInfo AGTileInfoMake(NSString *dataSet, NSInteger level, NSInteger x, NSInteger y);
static inline AGTileInfo
AGTileInfoMake(NSString *dataSet, NSInteger level, NSInteger x, NSInteger y)
{
AGTileInfo tInfo; tInfo.dataSet = dataSet; tInfo.level = level; tInfo.x = x; tInfo.y = y; return tInfo;
}
static inline bool AGTileInfoEqualToAGTile(AGTileInfo info1, AGTileInfo info2);
static inline bool
AGTileInfoEqualToAGTile(AGTileInfo info1, AGTileInfo info2)
{
return [info1.dataSet isEqualToString:info2.dataSet] && (info1.level==info2.level) && (info1.x == info2.x) && (info1.y == info2.y) ;
}
精彩评论