node ninja
node ninja

Reputation: 33026

Too few arguments to sqlite3_open in XCode

This line of code

if (sqlite3_open(([databasePath UTF8String], &database) == SQLITE_OK) 

generates an error saying that there are too few arguments to sqlite3_open. How many arguments are required? How can this be fixed?

Upvotes: 1

Views: 799

Answers (1)

martin clayton
martin clayton

Reputation: 78155

You've got your brackets in not quite the right place - so you're calling sqlite3_open( ) with just one argument, the result of the 'is-equal' test.

This is probably closer:

if ( sqlite3_open( [databasePath UTF8String], &database ) == SQLITE_OK ) 

See also the docs for sqlite3_open( ) - there are three alternative signatures, accepting 2 or 4 args:

int sqlite3_open(
  const char *filename,   /* Database filename (UTF-8) */
  sqlite3 **ppDb          /* OUT: SQLite db handle */
);
int sqlite3_open16(
  const void *filename,   /* Database filename (UTF-16) */
  sqlite3 **ppDb          /* OUT: SQLite db handle */
);
int sqlite3_open_v2(
  const char *filename,   /* Database filename (UTF-8) */
  sqlite3 **ppDb,         /* OUT: SQLite db handle */
  int flags,              /* Flags */
  const char *zVfs        /* Name of VFS module to use */
);

Upvotes: 3

Related Questions