C++ sqlite_version()

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

C++ sqlite_version()

papa
In my C++ program, I'd like to display the SQLite3 version. To do so,
this is what I have done.

class SQLite3_RDB {
     private:
         sqlite3* db; //!< Data Base
         std::string tmp;
    public:
         SQLite3_RDB(){}
         ~SQLite3_RDB(){sqlite3_close(db); }
         const std::string& getSQLiteVersion();

};

const std::string& SQLite3_RDB::getSQLiteVersion(){
     tmp = sqlite_version();
}

However, as soon as I call the getSQLiteVersion() class member function,
I get a "program failure". The gdb reports 'Signal received: SIGSEGV
(Segmentation fault)'
What am I doing wrong?

--
ArbolOne.ca
Using Fire Fox and Thunderbird.
ArbolOne is composed of students and volunteers dedicated to providing free services to charitable organizations.
ArbolOne on Java Development in progress [ í ]

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: C++ sqlite_version()

Keith Medcalf

sqlite3_version is not a function.  it is the "location" of the version string.

The definition of sqlite3_version is:

char sqlite3_version[];
equivalent to
char *sqlite3_version;

not a function that returns a pointer.  

It is a pointer to a zero terminated string (or rather the address of the first character of the zero-terminated version string)

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of Papa
>Sent: Friday, 25 August, 2017 20:56
>To: SQLite mailing list
>Subject: [sqlite] C++ sqlite_version()
>
>In my C++ program, I'd like to display the SQLite3 version. To do so,
>this is what I have done.
>
>class SQLite3_RDB {
>     private:
>         sqlite3* db; //!< Data Base
>         std::string tmp;
>    public:
>         SQLite3_RDB(){}
>         ~SQLite3_RDB(){sqlite3_close(db); }
>         const std::string& getSQLiteVersion();
>
>};
>
>const std::string& SQLite3_RDB::getSQLiteVersion(){
>     tmp = sqlite_version();
>}
>
>However, as soon as I call the getSQLiteVersion() class member
>function,
>I get a "program failure". The gdb reports 'Signal received: SIGSEGV
>(Segmentation fault)'
>What am I doing wrong?
>
>--
>ArbolOne.ca
>Using Fire Fox and Thunderbird.
>ArbolOne is composed of students and volunteers dedicated to
>providing free services to charitable organizations.
>ArbolOne on Java Development in progress [ í ]
>
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: C++ sqlite_version()

Keith Medcalf
In reply to this post by papa

https://sqlite.org/c3ref/libversion.html


---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume.


>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>[hidden email]] On Behalf Of Papa
>Sent: Friday, 25 August, 2017 20:56
>To: SQLite mailing list
>Subject: [sqlite] C++ sqlite_version()
>
>In my C++ program, I'd like to display the SQLite3 version. To do so,
>this is what I have done.
>
>class SQLite3_RDB {
>     private:
>         sqlite3* db; //!< Data Base
>         std::string tmp;
>    public:
>         SQLite3_RDB(){}
>         ~SQLite3_RDB(){sqlite3_close(db); }
>         const std::string& getSQLiteVersion();
>
>};
>
>const std::string& SQLite3_RDB::getSQLiteVersion(){
>     tmp = sqlite_version();
>}
>
>However, as soon as I call the getSQLiteVersion() class member
>function,
>I get a "program failure". The gdb reports 'Signal received: SIGSEGV
>(Segmentation fault)'
>What am I doing wrong?
>
>--
>ArbolOne.ca
>Using Fire Fox and Thunderbird.
>ArbolOne is composed of students and volunteers dedicated to
>providing free services to charitable organizations.
>ArbolOne on Java Development in progress [ í ]
>
>_______________________________________________
>sqlite-users mailing list
>[hidden email]
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: C++ sqlite_version()

Jens Alfke-2
In reply to this post by papa


> On Aug 25, 2017, at 7:56 PM, Papa <[hidden email]> wrote:
>
> const std::string& SQLite3_RDB::getSQLiteVersion(){
>     tmp = sqlite_version();
> }

sqlite_version() is not a function in SQLite itself; is it from some wrapper library you're using? Most likely the crash is in that function. Look at the crash backtrace.

—Jens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users