Rename DLL_API to –SQLITECPP_API, and add –visibility attribute for gcc

This commit is contained in:
Pierre Proske 2023-02-14 11:31:54 +11:00
parent 1eca00cb01
commit 060d5323c3
10 changed files with 56 additions and 52 deletions

View File

@ -32,7 +32,7 @@ namespace SQLite
* See also the a reference implementation of live backup taken from the official site: * See also the a reference implementation of live backup taken from the official site:
* https://www.sqlite.org/backup.html * https://www.sqlite.org/backup.html
*/ */
class DLL_API Backup class SQLITECPP_API Backup
{ {
public: public:
/** /**

View File

@ -23,11 +23,11 @@ struct sqlite3_stmt;
namespace SQLite namespace SQLite
{ {
DLL_API extern const int INTEGER; ///< SQLITE_INTEGER SQLITECPP_API extern const int INTEGER; ///< SQLITE_INTEGER
DLL_API extern const int FLOAT; ///< SQLITE_FLOAT SQLITECPP_API extern const int FLOAT; ///< SQLITE_FLOAT
DLL_API extern const int TEXT; ///< SQLITE_TEXT SQLITECPP_API extern const int TEXT; ///< SQLITE_TEXT
DLL_API extern const int BLOB; ///< SQLITE_BLOB SQLITECPP_API extern const int BLOB; ///< SQLITE_BLOB
DLL_API extern const int Null; ///< SQLITE_NULL SQLITECPP_API extern const int Null; ///< SQLITE_NULL
/** /**
* @brief Encapsulation of a Column in a row of the result pointed by the prepared Statement. * @brief Encapsulation of a Column in a row of the result pointed by the prepared Statement.
@ -45,7 +45,7 @@ DLL_API extern const int Null; ///< SQLITE_NULL
* because of the way it shares the underling SQLite precompiled statement * because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr"). * in a custom shared pointer (See the inner class "Statement::Ptr").
*/ */
class DLL_API Column class SQLITECPP_API Column
{ {
public: public:
/** /**
@ -242,7 +242,7 @@ private:
* *
* @return Reference to the stream used * @return Reference to the stream used
*/ */
DLL_API std::ostream& operator<<(std::ostream& aStream, const Column& aColumn); SQLITECPP_API std::ostream& operator<<(std::ostream& aStream, const Column& aColumn);
#if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900) // c++14: Visual Studio 2015 #if __cplusplus >= 201402L || (defined(_MSC_VER) && _MSC_VER >= 1900) // c++14: Visual Studio 2015

View File

@ -85,37 +85,37 @@ namespace SQLite
// Those public constants enable most usages of SQLiteCpp without including <sqlite3.h> in the client application. // Those public constants enable most usages of SQLiteCpp without including <sqlite3.h> in the client application.
/// The database is opened in read-only mode. If the database does not already exist, an error is returned. /// The database is opened in read-only mode. If the database does not already exist, an error is returned.
DLL_API extern const int OPEN_READONLY; // SQLITE_OPEN_READONLY SQLITECPP_API extern const int OPEN_READONLY; // SQLITE_OPEN_READONLY
/// The database is opened for reading and writing if possible, or reading only if the file is write protected /// The database is opened for reading and writing if possible, or reading only if the file is write protected
/// by the operating system. In either case the database must already exist, otherwise an error is returned. /// by the operating system. In either case the database must already exist, otherwise an error is returned.
DLL_API extern const int OPEN_READWRITE; // SQLITE_OPEN_READWRITE SQLITECPP_API extern const int OPEN_READWRITE; // SQLITE_OPEN_READWRITE
/// With OPEN_READWRITE: The database is opened for reading and writing, and is created if it does not already exist. /// With OPEN_READWRITE: The database is opened for reading and writing, and is created if it does not already exist.
DLL_API extern const int OPEN_CREATE; // SQLITE_OPEN_CREATE SQLITECPP_API extern const int OPEN_CREATE; // SQLITE_OPEN_CREATE
/// Enable URI filename interpretation, parsed according to RFC 3986 (ex. "file:data.db?mode=ro&cache=private") /// Enable URI filename interpretation, parsed according to RFC 3986 (ex. "file:data.db?mode=ro&cache=private")
DLL_API extern const int OPEN_URI; // SQLITE_OPEN_URI SQLITECPP_API extern const int OPEN_URI; // SQLITE_OPEN_URI
/// Open in memory database /// Open in memory database
DLL_API extern const int OPEN_MEMORY; // SQLITE_OPEN_MEMORY SQLITECPP_API extern const int OPEN_MEMORY; // SQLITE_OPEN_MEMORY
/// Open database in multi-thread threading mode /// Open database in multi-thread threading mode
DLL_API extern const int OPEN_NOMUTEX; // SQLITE_OPEN_NOMUTEX SQLITECPP_API extern const int OPEN_NOMUTEX; // SQLITE_OPEN_NOMUTEX
/// Open database with thread-safety in serialized threading mode /// Open database with thread-safety in serialized threading mode
DLL_API extern const int OPEN_FULLMUTEX; // SQLITE_OPEN_FULLMUTEX SQLITECPP_API extern const int OPEN_FULLMUTEX; // SQLITE_OPEN_FULLMUTEX
/// Open database with shared cache enabled /// Open database with shared cache enabled
DLL_API extern const int OPEN_SHAREDCACHE; // SQLITE_OPEN_SHAREDCACHE SQLITECPP_API extern const int OPEN_SHAREDCACHE; // SQLITE_OPEN_SHAREDCACHE
/// Open database with shared cache disabled /// Open database with shared cache disabled
DLL_API extern const int OPEN_PRIVATECACHE; // SQLITE_OPEN_PRIVATECACHE SQLITECPP_API extern const int OPEN_PRIVATECACHE; // SQLITE_OPEN_PRIVATECACHE
/// Database filename is not allowed to be a symbolic link (Note: only since SQlite 3.31.0 from 2020-01-22) /// Database filename is not allowed to be a symbolic link (Note: only since SQlite 3.31.0 from 2020-01-22)
DLL_API extern const int OPEN_NOFOLLOW; // SQLITE_OPEN_NOFOLLOW SQLITECPP_API extern const int OPEN_NOFOLLOW; // SQLITE_OPEN_NOFOLLOW
DLL_API extern const int OK; ///< SQLITE_OK (used by check() bellow) SQLITECPP_API extern const int OK; ///< SQLITE_OK (used by check() bellow)
DLL_API extern const char* const VERSION; ///< SQLITE_VERSION string from the sqlite3.h used at compile time SQLITECPP_API extern const char* const VERSION; ///< SQLITE_VERSION string from the sqlite3.h used at compile time
DLL_API extern const int VERSION_NUMBER; ///< SQLITE_VERSION_NUMBER from the sqlite3.h used at compile time SQLITECPP_API extern const int VERSION_NUMBER; ///< SQLITE_VERSION_NUMBER from the sqlite3.h used at compile time
/// Return SQLite version string using runtime call to the compiled library /// Return SQLite version string using runtime call to the compiled library
DLL_API const char* getLibVersion() noexcept; SQLITECPP_API const char* getLibVersion() noexcept;
/// Return SQLite version number using runtime call to the compiled library /// Return SQLite version number using runtime call to the compiled library
DLL_API int getLibVersionNumber() noexcept; SQLITECPP_API int getLibVersionNumber() noexcept;
// Public structure for representing all fields contained within the SQLite header. // Public structure for representing all fields contained within the SQLite header.
// Official documentation for fields: https://www.sqlite.org/fileformat.html#the_database_header // Official documentation for fields: https://www.sqlite.org/fileformat.html#the_database_header
@ -161,7 +161,7 @@ struct Header {
* because of the way it shares the underling SQLite precompiled statement * because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr"). * in a custom shared pointer (See the inner class "Statement::Ptr").
*/ */
class DLL_API Database class SQLITECPP_API Database
{ {
friend class Statement; // Give Statement constructor access to the mSQLitePtr Connection Handle friend class Statement; // Give Statement constructor access to the mSQLitePtr Connection Handle
@ -266,7 +266,7 @@ public:
// Deleter functor to use with smart pointers to close the SQLite database connection in an RAII fashion. // Deleter functor to use with smart pointers to close the SQLite database connection in an RAII fashion.
struct Deleter struct Deleter
{ {
DLL_API void operator()(sqlite3* apSQLite); SQLITECPP_API void operator()(sqlite3* apSQLite);
}; };
/** /**

View File

@ -24,7 +24,7 @@ namespace SQLite
/** /**
* @brief Encapsulation of the error message from SQLite3, based on std::runtime_error. * @brief Encapsulation of the error message from SQLite3, based on std::runtime_error.
*/ */
class DLL_API Exception : public std::runtime_error class SQLITECPP_API Exception : public std::runtime_error
{ {
public: public:
/** /**

View File

@ -20,14 +20,18 @@
/* Windows DLL export/import */ /* Windows DLL export/import */
#if defined(_WIN32) && defined(SQLITECPP_COMPILE_DLL) #if defined(_WIN32) && defined(SQLITECPP_COMPILE_DLL)
#if SQLITECPP_DLL_EXPORT #if SQLITECPP_DLL_EXPORT
#define DLL_API __declspec(dllexport) #define SQLITECPP_API __declspec(dllexport)
#pragma message("Exporting symbols") #pragma message("Exporting symbols")
#else #else
#define DLL_API __declspec(dllimport) #define SQLITECPP_API __declspec(dllimport)
#pragma message("Importing symbols") #pragma message("Importing symbols")
#endif #endif
#else #else
#define DLL_API #if __GNUC__ >= 4
#define SQLITECPP_API __attribute__ ((visibility ("default")))
#else
#define SQLITECPP_API
#endif
#endif #endif
#if defined(WIN32) && defined(SQLITECPP_COMPILE_DLL) #if defined(WIN32) && defined(SQLITECPP_COMPILE_DLL)

View File

@ -54,7 +54,7 @@ class Database;
* because of the way it shares the underling SQLite precompiled statement * because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr"). * in a custom shared pointer (See the inner class "Statement::Ptr").
*/ */
class DLL_API Savepoint class SQLITECPP_API Savepoint
{ {
public: public:
/** /**

View File

@ -31,7 +31,7 @@ namespace SQLite
class Database; class Database;
class Column; class Column;
DLL_API extern const int OK; ///< SQLITE_OK SQLITECPP_API extern const int OK; ///< SQLITE_OK
/** /**
* @brief RAII encapsulation of a prepared SQLite Statement. * @brief RAII encapsulation of a prepared SQLite Statement.
@ -50,7 +50,7 @@ DLL_API extern const int OK; ///< SQLITE_OK
* because of the way it shares the underling SQLite precompiled statement * because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr"). * in a custom shared pointer (See the inner class "Statement::Ptr").
*/ */
class DLL_API Statement class SQLITECPP_API Statement
{ {
public: public:
/** /**

View File

@ -51,7 +51,7 @@ enum class TransactionBehavior {
* because of the way it shares the underling SQLite precompiled statement * because of the way it shares the underling SQLite precompiled statement
* in a custom shared pointer (See the inner class "Statement::Ptr"). * in a custom shared pointer (See the inner class "Statement::Ptr").
*/ */
class DLL_API Transaction class SQLITECPP_API Transaction
{ {
public: public:
/** /**

View File

@ -18,11 +18,11 @@
namespace SQLite namespace SQLite
{ {
DLL_API const int INTEGER = SQLITE_INTEGER; SQLITECPP_API const int INTEGER = SQLITE_INTEGER;
DLL_API const int FLOAT = SQLITE_FLOAT; SQLITECPP_API const int FLOAT = SQLITE_FLOAT;
DLL_API const int TEXT = SQLITE_TEXT; SQLITECPP_API const int TEXT = SQLITE_TEXT;
DLL_API const int BLOB = SQLITE_BLOB; SQLITECPP_API const int BLOB = SQLITE_BLOB;
DLL_API const int Null = SQLITE_NULL; SQLITECPP_API const int Null = SQLITE_NULL;
// Encapsulation of a Column in a row of the result pointed by the prepared Statement. // Encapsulation of a Column in a row of the result pointed by the prepared Statement.

View File

@ -26,25 +26,25 @@
namespace SQLite namespace SQLite
{ {
DLL_API const int OK = SQLITE_OK; SQLITECPP_API const int OK = SQLITE_OK;
DLL_API const int OPEN_READONLY = SQLITE_OPEN_READONLY; SQLITECPP_API const int OPEN_READONLY = SQLITE_OPEN_READONLY;
DLL_API const int OPEN_READWRITE = SQLITE_OPEN_READWRITE; SQLITECPP_API const int OPEN_READWRITE = SQLITE_OPEN_READWRITE;
DLL_API const int OPEN_CREATE = SQLITE_OPEN_CREATE; SQLITECPP_API const int OPEN_CREATE = SQLITE_OPEN_CREATE;
DLL_API const int OPEN_URI = SQLITE_OPEN_URI; SQLITECPP_API const int OPEN_URI = SQLITE_OPEN_URI;
DLL_API const int OPEN_MEMORY = SQLITE_OPEN_MEMORY; SQLITECPP_API const int OPEN_MEMORY = SQLITE_OPEN_MEMORY;
DLL_API const int OPEN_NOMUTEX = SQLITE_OPEN_NOMUTEX; SQLITECPP_API const int OPEN_NOMUTEX = SQLITE_OPEN_NOMUTEX;
DLL_API const int OPEN_FULLMUTEX = SQLITE_OPEN_FULLMUTEX; SQLITECPP_API const int OPEN_FULLMUTEX = SQLITE_OPEN_FULLMUTEX;
DLL_API const int OPEN_SHAREDCACHE = SQLITE_OPEN_SHAREDCACHE; SQLITECPP_API const int OPEN_SHAREDCACHE = SQLITE_OPEN_SHAREDCACHE;
DLL_API const int OPEN_PRIVATECACHE = SQLITE_OPEN_PRIVATECACHE; SQLITECPP_API const int OPEN_PRIVATECACHE = SQLITE_OPEN_PRIVATECACHE;
// check if sqlite version is >= 3.31.0 and SQLITE_OPEN_NOFOLLOW is defined // check if sqlite version is >= 3.31.0 and SQLITE_OPEN_NOFOLLOW is defined
#if SQLITE_VERSION_NUMBER >= 3031000 && defined(SQLITE_OPEN_NOFOLLOW) #if SQLITE_VERSION_NUMBER >= 3031000 && defined(SQLITE_OPEN_NOFOLLOW)
DLL_API const int OPEN_NOFOLLOW = SQLITE_OPEN_NOFOLLOW; SQLITECPP_API const int OPEN_NOFOLLOW = SQLITE_OPEN_NOFOLLOW;
#else #else
DLL_API const int OPEN_NOFOLLOW = 0; SQLITECPP_API const int OPEN_NOFOLLOW = 0;
#endif #endif
DLL_API const char* const VERSION = SQLITE_VERSION; SQLITECPP_API const char* const VERSION = SQLITE_VERSION;
DLL_API const int VERSION_NUMBER = SQLITE_VERSION_NUMBER; SQLITECPP_API const int VERSION_NUMBER = SQLITE_VERSION_NUMBER;
// Return SQLite version string using runtime call to the compiled library // Return SQLite version string using runtime call to the compiled library
const char* getLibVersion() noexcept const char* getLibVersion() noexcept