I am developing iPhone application which is using the 3 projects. One project is developed with the combination of c and c++ code and one is on Objective C and one is to link both (Objective-C and C and C++ project) the project.
Now when I am compiling my C and C++ project in GCC compiler it compiles perfectly but when I am compiling the same project with LLVM-GCC compiler it’s throwing error of ‘Initilizer element is not a constant’.
#define MY_WSD const
struct FuncDef {
i8 nArg;
u8 iPrefEnc;
u8 needCollSeq;
u8 flags;
void *pUserData;
FuncDef *pNext;
char *zName;
FuncDef *pHash;
};
typedef struct FuncDef FuncDef;
#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
{nArg, SQLITE_UTF8, bNC, 0, SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName}
Here is the code responsible for error:
void myDateTimeFunctions(void){
static MY_WSD FuncDef aDateTimeFuncs[] = {
FUNCTION(julianday, -1, 0, 0, juliandayFunc ), //when I compile the code with LLVM GCC it's giving me error
//at this line and the later line and working fine with GCC
//alone compiler. But the problem is XCode 4.2 does not come
//with GCC alone compiler, so I am unable to run the applciation.
FUNCTION(date, -1, 0, 0, dateFunc ),
};
Please let me know if I am missing some valuable info for the bug to be fixed.
Hey thanks for your all supports and answer I got the answer of the question. It was the problem with the macro SQLITE_INT_TO_PTR defined in sqlite.c and it was the problem rreported long back with the LLVM_GCC compiler. Actually it is needed to redefine the macro and it will solve the problem.
Here is the reference for the same: http://tribelet.blogspot.com/2008/09/blog-post_08.html
language of the post is Japanese but it helped me to get out of the problem.