Mst137 Mst137 - 1 year ago 60
C Question

Conflicting Types in function

This function has worked and compiled fine for the past few days however now is giving me and error that reads:

"conflicting types for 'PrepareSQLRead'"

Below is the function that is having the issues,

sqlite3_stmt* PrepareSQLRead(sqlite3 *db, char* TableToRead){

int rc;
char SQL2[128];
sqlite3_stmt* SQL;
sprintf(SQL2, "SELECT * from %s", TableToRead);
printf("%s\n", SQL2);
rc = sqlite3_prepare_v2(db,SQL2,-1, &SQL, 0);
if (rc) {
fprintf(stderr, "Can't prepare statement: %s\n",
return NULL;
} else {
fprintf(stderr, "Statement prepared successfully\n");

return SQL;}

I really don't understand why I am now getting this issue as I haven't even changed the function contents since it worked fine.

Answer Source

That error message is telling you exactly what's happening - there is an implicit declaration of PrepareSQLRead because you don't declare explicitly before main(). Might be add a forward declaration before main:

sqlite3_stmt* PrepareSQLRead(sqlite3, char*);