verref.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. /* This header is used inline in a function to ensure that a version string
  5. * symbol is linked in and not optimized out. A volatile reference is added to
  6. * the variable identified by NSS_VERSION_VARIABLE.
  7. *
  8. * Use this as follows:
  9. *
  10. * #define NSS_VERSION_VARIABLE __nss_ssl_version
  11. * #include "verref.h"
  12. */
  13. /* Suppress unused variable warnings. */
  14. #ifdef _MSC_VER
  15. #pragma warning(push)
  16. #pragma warning(disable : 4101)
  17. #endif
  18. /* This works for both gcc and clang */
  19. #if defined(__GNUC__) && !defined(NSS_NO_GCC48)
  20. #pragma GCC diagnostic push
  21. #pragma GCC diagnostic ignored "-Wunused-variable"
  22. #endif
  23. #ifndef NSS_VERSION_VARIABLE
  24. #error NSS_VERSION_VARIABLE must be set before including "verref.h"
  25. #endif
  26. {
  27. extern const char NSS_VERSION_VARIABLE[];
  28. #if defined(__GNUC__)
  29. __attribute__((unused))
  30. #endif
  31. volatile const char _nss_version_c = NSS_VERSION_VARIABLE[0];
  32. }
  33. #undef NSS_VERSION_VARIABLE
  34. #ifdef _MSC_VER
  35. #pragma warning(pop)
  36. #endif
  37. #if defined(__GNUC__) && !defined(NSS_NO_GCC48)
  38. #pragma GCC diagnostic pop
  39. #endif