multiInclude.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Multi-include test program
  3. * Validates that xxhash.h can be included multiple times and in any order
  4. *
  5. * Copyright (C) 2020 Yann Collet
  6. *
  7. * GPL v2 License
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. *
  23. * You can contact the author at:
  24. * - xxHash homepage: https://www.xxhash.com
  25. * - xxHash source repository: https://github.com/Cyan4973/xxHash
  26. */
  27. #include <stdio.h> /* printf */
  28. /* Normal include, gives access to public symbols */
  29. #include "../xxhash.h"
  30. /*
  31. * Advanced include, gives access to experimental symbols
  32. * This test ensure that xxhash.h can be included multiple times and in any
  33. * order. This order is more difficult: Without care, the declaration of
  34. * experimental symbols could be skipped.
  35. */
  36. #define XXH_STATIC_LINKING_ONLY
  37. #include "../xxhash.h"
  38. /*
  39. * Inlining: Re-define all identifiers, keep them private to the unit.
  40. * Note: Without specific efforts, the identifier names would collide.
  41. *
  42. * To be linked with and without xxhash.o to test the symbol's presence and
  43. * naming collisions.
  44. */
  45. #define XXH_INLINE_ALL
  46. #include "../xxhash.h"
  47. int main(void)
  48. {
  49. XXH3_state_t state; /* part of experimental API */
  50. XXH3_64bits_reset(&state);
  51. const char input[] = "Hello World !";
  52. XXH3_64bits_update(&state, input, sizeof(input));
  53. XXH64_hash_t const h = XXH3_64bits_digest(&state);
  54. printf("hash '%s': %08x%08x \n", input, (unsigned)(h >> 32), (unsigned)h);
  55. return 0;
  56. }