Reputation: 1353
I would like to know how to make the compiler understand a customized argument for #pragma
macro.
My goal is to execute external script using macro, I suppose using #pragma
is the way to go; if there are other ways to do so, please let me know.
Syntax would be something like:
#pragma add_controller(class_name, "class_alias")
so that I can generate a dynamic .h file containing the following:
register_controller<class_name>("class_alias");
and append to the end of file everytime the compiler interpret this #pragma
.
Upvotes: 6
Views: 3078
Reputation: 8641
pragmas are builtin features of a compiler, and compiler-specific. You can't change or extend them in the general case, unless you're willing to tamper with the compiler itself.
Asking programmers to use a custom built compiler is probably not the best way to make your code more useable :).
For your example, you could use a macro:
#define add_controller(name, alias) register_controller<name>(alias)
and use it like so:
add_controller(whatever_controller, "whatever_alias");
Upvotes: 7