Zaratruta
Zaratruta

Reputation: 2285

Is there any kind of metaprogramming in C?

I know that there are some possibilities os metaprogramming in languages like Python and Java. We can introspect the functions, classes, types of an object and modify them at runtime.

Is it possible to do something similar in C?

Upvotes: 1

Views: 440

Answers (1)

paulsm4
paulsm4

Reputation: 121649

Short answer: "No".

  • Java and C# (among others) support reflection: the ability to examine and manipulate a class from within itself at runtime

  • JavaScript, PHP, Lua and Perl (among others) are considered "Dynamic programming languages": they can be modified on-the-fly as the program executes.

"Static languages" like C, C++, FORTRAN, etc. have no such capabilities.

You can, to some extent, "emulate" similar functionality. But it's not directly supported by the language itself, and any such "emulations" will almost inevitably have "limitations".

Upvotes: 2

Related Questions