shiva
last version
last version
  • Shiva Documentation
  • Shiva
    • Changelog
    • FAQ
    • Gallery
    • Installation
    • Modules
      • shiva::box2d
      • shiva::dll
      • shiva::ecs
      • shiva::entt
      • shiva::enums
      • shiva::error
      • shiva::event
      • shiva::filesystem
      • shiva::input
      • shiva::json
      • shiva::lua
      • shiva::meta
      • shiva::pp
      • shiva::pyscripting
      • shiva::range
      • shiva::reflection
      • shiva::scenes
      • shiva::sfml
        • shiva::system-sfml-animation
        • shiva::system-sfml-graphics
        • shiva::system-sfml-inputs
        • shiva::system-sfml-resources
      • shiva::spdlog
      • shiva::stacktrace
      • shiva::timer
      • shiva::world
    • Roadmap
    • Scripting
      • Lua
      • Python
    • Tutorial
      • Quick'start
      • How to create/build/install a system plugin
      • How to create a scripted system
      • How to create a project through the CLI tools and build it
Powered by GitBook
On this page
  • shiva::pp
  • pp_stringify, pp_stringviewify
  • pp_paste
  • pp_first_arg
  • pp_count_args
  • pp_for_each
  1. Shiva
  2. Modules

shiva::pp

shiva::pp

shiva::pp provides basic preprocessing utilities.

pp_stringify, pp_stringviewify

The pp_stringify macro allows converting its parameter to a string litteral.

pp_stringify(param)
const char *str = pp_stringify(hello);
//str is now "hello"

The pp_stringviewify macro allows converting its parameter to a constexpr std::string_view.

pp_stringviewify(param)
constexpr std::string_view sv = pp_stringviewify(hello);
//sv is now {"hello", 5}

pp_paste

The pp_paste macro allows concatenating its parameters together to form a new token.

pp_paste(param1, param2)
int var1 = 1;
pp_paste(var, 1) = 2;
//var1 is now 2

pp_first_arg

The pp_first_arg macro allows extracting the first parameter from a variadic macro parameter list (usually represented as __VA_ARGS__).

pp_first_arg(...)
int first = pp_first_arg(1, 2, 3);
//first is now 1

pp_count_args

The pp_count_args macro allows counting the number of parameters passed to a variadic macro.

pp_count_args(...)
int nb = pp_count_args(1, 2, 3, 4, 5);
//nb is now 5

pp_for_each

The pp_for_each macro allows applying a given macro to each argument of a variadic macro parameter list.

pp_for_each(apply, ...)
#define doubleParam(a)      (a * 2),

std::vector<int> v{pp_for_each(doubleParam, 1, 2, 3)};
//v is now {2, 4, 6}
#define incrementIBy(nb)    i += nb;

int i = 0;
pp_for_each(incrementIBy, 1, 2, 3);
//i is now 6
Previousshiva::metaNextshiva::pyscripting

Last updated 6 years ago