[wxSQLite3] wxSQLite3Database::TableExists and MinGW Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
lrm
Earned a small fee
Earned a small fee
Posts: 10
Joined: Sat Nov 20, 2004 9:12 pm
Location: San Jos

[wxSQLite3] wxSQLite3Database::TableExists and MinGW

Post by lrm »

During compiling time of wxSQLite3 in UNICODE mode, I got the following warning:

warning: cannot pass objects of non-POD type `const class wxCharBuffer' through `...'; call will abort at runtime

This correspond to wxSQLite3Database::TableExists. When I use this function in a program, the app crash (seems a sprintf problem).

Compiler: gcc (GCC) 3.4.4 (mingw special)
wxWidgets: 2.6.2 (UNICODE)
wxSQLite3: 1.3.1 (UNICODE)
IDE: Code::Blocks RC2


Note: Sorry for my poor english :oops:
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: [wxSQLite3] wxSQLite3Database::TableExists and MinGW

Post by utelle »

lrm wrote:During compiling time of wxSQLite3 in UNICODE mode, I got the following warning:

warning: cannot pass objects of non-POD type `const class wxCharBuffer' through `...'; call will abort at runtime

This correspond to wxSQLite3Database::TableExists. When I use this function in a program, the app crash (seems a sprintf problem).

Compiler: gcc (GCC) 3.4.4 (mingw special)
wxWidgets: 2.6.2 (UNICODE)
wxSQLite3: 1.3.1 (UNICODE)
IDE: Code::Blocks RC2
I use VC6 for development on Windows with the highest possible warning level, but no warning ... and no crash. Nevertheless the gcc warning is correct and the code should be fixed to eliminate that warning. Fortunately the solution is simple:

Please change the lines in method wxSQLite3Database::TableExists from

Code: Select all

sprintf(localSql,
        "select count(*) from sqlite_master where type='table' and name='%s'",
        localTableName);
to

Code: Select all

sprintf(localSql,
        "select count(*) from sqlite_master where type='table' and name='%s'",
        (const char*) localTableName);
That is, add an explicit cast of (const char*) for the sprintf argument localTableName.

Regards,

Ulrich
lrm
Earned a small fee
Earned a small fee
Posts: 10
Joined: Sat Nov 20, 2004 9:12 pm
Location: San Jos

Post by lrm »

Thanks for help
Post Reply