Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgraded to Xcode 4.1 and sqlite3.h is causing compilation errors where it didn't before the upgrade

I recently opened an existing project from a time before I installed Xcode 4.1. At first there were many errors and I corrected the problem by chosing LLVM 2.1 as the option for the compiler. All of the errors but one have been cleared up, in sqlite3.h this line is causing a problem:

SQLITE_API int sqlite3_enable_shared_cache(int) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_2_0, __IPHONE_5_0);

The error message reads:

Expected function body after function declarator.

Any help is greatly appreciated,

Thanks!

like image 856
Nirma Avatar asked Jul 26 '11 21:07

Nirma


2 Answers

I had the same problem. I changed my code which said

#include "/usr/include/sqlite3.h"

to

#include <sqlite3.h>

and that fixed it. Perhaps you are picking up the wrong header file somehow.

like image 103
SpaceCoaster Avatar answered Sep 28 '22 05:09

SpaceCoaster


i had the same problem. Opened an old project in latest Xcode. sqllite3.h causing errors.

I noticed if you click on the sqlite3.h in your code that caused the error and open it in xcode, the right click and show in finder you get

/usr/include/sqlite3.h

yet when you go to the dylib

 Project > Targets > Project Name > Build Phases tab > Link Binary with Library section > libsqlite3.lib > right click and Show in Finder

you get

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libsqlite3.lib

and the headers for this are in a parallel folder

/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/include/sqllite3.h

more importantly the .h files were different versions

The one in the iPhone SDk dir was

#define SQLITE_VERSION        "3.7.2"

The one in the Mac /usr/include

#define SQLITE_VERSION        "3.7.5"

in /usr/include SQLITE_VERSION "3.7.5" the macro throwing the error is defined __OSX_AVAILABLE_BUT_DEPRECATED

SQLITE_API int sqlite3_enable_shared_cache(int) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_7, __IPHONE_2_0, __IPHONE_5_0);

But In The one in the iPhone SDk 4.3 / sqlite "3.7.2"

SQLITE_API int sqlite3_enable_shared_cache(int);

for same definition its not.

the fix mentioned above works

 CHANGE EVERY #include "/usr/include/sqlite3.h"

to

#include <sqlite3.h>
like image 35
brian.clear Avatar answered Sep 28 '22 05:09

brian.clear