sqlite3.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (c) 2010 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef THIRD_PARTY_SQLITE_SQLITE3_H_
  5. #define THIRD_PARTY_SQLITE_SQLITE3_H_
  6. // This is a shim header to include the right sqlite3 headers.
  7. // Use this instead of referencing sqlite3 headers directly.
  8. // We prefix chrome_ to SQLite's exported symbols, so that we don't clash with
  9. // other SQLite libraries loaded by the system libraries. This only matters when
  10. // using the component build, where our SQLite's symbols are visible to the
  11. // dynamic library loader.
  12. #include "third_party/sqlite/src/amalgamation/rename_exports.h"
  13. #if defined(SQLITE_OMIT_COMPLETE)
  14. // When SQLITE_OMIT_COMPLETE is defined, sqlite3.h does not emit a declaration
  15. // for sqlite3_complete(). SQLite's shell.c stubs out the function by #defining
  16. // a macro.
  17. //
  18. // In order to avoid a macro redefinition warning, we must undo the #define in
  19. // rename_exports.h.
  20. //
  21. // Historical note: SQLite's shell.c initially did not support building against
  22. // a libary with SQLITE_OMIT_COMPLETE at all. The first attempt at adding
  23. // support was https://www.sqlite.org/src/info/c3e816cca4ddf096 which defined
  24. // sqlite_complete() as a stub function in shell.c. This worked on UNIX systems,
  25. // but caused a compilation error on Windows, where sqlite3.h declares
  26. // sqlite3_complete() as a __declspec(dllimport). The Windows build error was
  27. // fixed in https://www.sqlite.org/src/info/d584a0cb51281594 at our request.
  28. // While the current approach of using a macro requires the workaround here, it
  29. // is preferable to the previous version, which did not build at all on Windows.
  30. #if defined(sqlite3_complete)
  31. #undef sqlite3_complete
  32. #else
  33. #error "This workaround is no longer needed."
  34. #endif // !defined(sqlite3_complete)
  35. #endif // defined(SQLITE_OMIT_COMPLETE)
  36. #if defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
  37. // When SQLITE_OMIT_COMPILEOPTION_DIAGS is defined, sqlite3.h emits macros
  38. // instead of declarations for sqlite3_compileoption_{get,used}().
  39. //
  40. // In order to avoid a macro redefinition warning, we must undo the #define in
  41. // rename_exports.h.
  42. #if defined(sqlite3_compileoption_get)
  43. #undef sqlite3_compileoption_get
  44. #else
  45. #error "This workaround is no longer needed."
  46. #endif // !defined(sqlite3_compileoption_get)
  47. #if defined(sqlite3_compileoption_used)
  48. #undef sqlite3_compileoption_used
  49. #else
  50. #error "This workaround is no longer needed."
  51. #endif // !defined(sqlite3_compileoption_used)
  52. #endif // defined(SQLITE_OMIT_COMPILEOPTION_DIAGS)
  53. #include "third_party/sqlite/src/amalgamation/sqlite3.h"
  54. #endif // THIRD_PARTY_SQLITE_SQLITE3_H_