Skip to content

jerome-quere/cthis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

cthis

This C library is not meant to be used in real life project ! This Hack will allow you to simulate the "this" mechanism. Well known in object oriented-languages this lib bring it to the C languages.

  • Create a class using struct
  • Add a function pointer in it
  • Call the cthis_bind0p function to bind the struct pointer and the function

Exemple

struct Foo
{
  void (*bar)();
}

static void foo_bar(Foo* this)
{
  //Have fun with `this`
}

int main()
{
  Foo foo;
  foo.bar = cthis_bind0p(&foo, &Foo_bar);
  foo.bar();
}

About

This code is based on a Jules Baratoux [email protected] original idea.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages