Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Macros
pre_main_call.hpp File Reference

Provides a macro to call a lambda before main. More...

#include "shambase/unique_name_macro.hpp"
+ Include dependency graph for pre_main_call.hpp:

Go to the source code of this file.

Macros

#define PRE_MAIN_FUNCTION_CALL_NAMED(class_name, instance_name, lambda)
 Macro to call a lambda or a function before main.
 
#define PRE_MAIN_FUNCTION_CALL(lambda)
 Macro to call a lambda or a function before main with a automatically generated unique name.
 

Detailed Description

Provides a macro to call a lambda before main.

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file pre_main_call.hpp.

Macro Definition Documentation

◆ PRE_MAIN_FUNCTION_CALL

#define PRE_MAIN_FUNCTION_CALL (   lambda)
Value:
__shamrock_unique_name(_PRE_MAIN_FUNCTION_CALL), \
__shamrock_unique_name(_PRE_MAIN_FUNCTION_CALL_INSTANCE), \
lambda)
#define PRE_MAIN_FUNCTION_CALL_NAMED(class_name, instance_name, lambda)
Macro to call a lambda or a function before main.

Macro to call a lambda or a function before main with a automatically generated unique name.

Usage :

int pre_main_call_counter = 0;
pre_main_call_counter++;
});
PRE_MAIN_FUNCTION_CALL(pre_main_call_function);
#define PRE_MAIN_FUNCTION_CALL(lambda)
Macro to call a lambda or a function before main with a automatically generated unique name.
Parameters
lambdaThe lambda or function to call

Definition at line 45 of file pre_main_call.hpp.

◆ PRE_MAIN_FUNCTION_CALL_NAMED

#define PRE_MAIN_FUNCTION_CALL_NAMED (   class_name,
  instance_name,
  lambda 
)
Value:
namespace { \
struct class_name { \
class_name() { lambda(); } \
}; \
static const class_name instance_name{}; \
}

Macro to call a lambda or a function before main.

Definition at line 22 of file pre_main_call.hpp.