A collection of basic/generally desirable code I use across multiple C++ projects.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
2.7 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #pragma once
  2. #ifndef ULE_TYPES_H
  3. #define ULE_TYPES_H
  4. #include <stddef.h> // size_t
  5. #define null 0
  6. #ifndef ULE_TYPES_H_FTAG
  7. #ifdef ULE_CONFIG_OPTION_FTAG
  8. #define ULE_TYPES_H_FTAG ULE_CONFIG_OPTION_FTAG
  9. #else
  10. #define ULE_TYPES_H_FTAG
  11. #endif
  12. #endif
  13. // The restrict declspec is used on functions that return unaliased pointers. This keyword is used for the C-Runtime Library implementation of malloc since it will never return a pointer value that is already in use in the current program (unless you are doing something illegal, such as using memory after it has been freed).
  14. // https://learn.microsoft.com/en-us/cpp/cpp/restrict?view=msvc-170
  15. // @NOTE(gingerbill posted this):
  16. //#if !defined(restrict)
  17. // #if defined(_MSC_VER)
  18. // #define shard_restrict __restrict
  19. // #elif defined(__STDC_VERSION__)
  20. // #define shard_restrict restrict
  21. // #else
  22. // #define shard_restrict
  23. // #endif
  24. //#endif
  25. // The noalias declspec is also applied only to functions, and indicates that the function is a semi-pure function. A semi-pure function is one that references or modifies only locals, arguments, and first-level indirections of arguments. This declspec is a promise to the compiler, and if the function references globals or second-level indirections of pointer arguments then the compiler may generate code that breaks the application.
  26. // https://learn.microsoft.com/en-us/cpp/cpp/noalias?view=msvc-170
  27. // char
  28. // unsigned char
  29. #include <stdint.h>
  30. typedef uint64_t u64;
  31. typedef uint32_t u32;
  32. typedef uint16_t u16;
  33. typedef uint8_t u8;
  34. typedef int64_t s64;
  35. typedef int32_t s32;
  36. typedef int16_t s16;
  37. typedef int8_t s8;
  38. //typedef size_t size_t;
  39. // we use the standard C names for IEEE-754 binary64 and binary32 (double, float). we don't use 'extended'.
  40. //typedef float float;
  41. //typedef double double;
  42. //typedef long double extended;
  43. // if we're using the glm vector/matrix types, or other types, define them here
  44. #ifdef ULE_CONFIG_OPTION_USE_GLM
  45. // force high precision for everything
  46. #define GLM_PRECISION_HIGHP_FLOAT
  47. #define GLM_PRECISION_HIGHP_DOUBLE
  48. #define GLM_PRECISION_HIGHP_INT
  49. #define GLM_PRECISION_HIGHP_UINT
  50. #include <glm/glm.hpp>
  51. #include <glm/gtc/matrix_transform.hpp>
  52. #endif
  53. typedef enum TypeEnum {
  54. TypeEnum_bool,
  55. TypeEnum_char,
  56. TypeEnum_uchar,
  57. TypeEnum_u8,
  58. TypeEnum_u16,
  59. TypeEnum_u32,
  60. TypeEnum_u64,
  61. TypeEnum_s8,
  62. TypeEnum_s16,
  63. TypeEnum_s32,
  64. TypeEnum_s64,
  65. #ifndef _WIN32
  66. TypeEnum_size_t,
  67. #endif
  68. TypeEnum_float,
  69. TypeEnum_double,
  70. #ifdef _USING_GLM_TYPES__
  71. TypeEnum_vec2,
  72. TypeEnum_vec3,
  73. TypeEnum_vec4,
  74. TypeEnum_mat2,
  75. TypeEnum_mat3,
  76. TypeEnum_mat4,
  77. #endif
  78. } TypeEnum;
  79. #endif