Opened 11 years ago

Last modified 11 years ago

#271 new task

RFC: replace static member CBs with extern C proxies?

Reported by: epruesse Owned by: devel
Priority: normal Milestone:
Component: global Version: SVN
Keywords: Cc:

Description

http://stackoverflow.com/questions/2068022/in-c-is-it-safe-portable-to-use-static-member-function-pointer-for-c-api-call

In summary: calling static member functions isn't allowed by the standard. It does work for GCC and CLANG, though.

What do we do?

  1. ignore this and implement in whatever way we feel like on a given day
  2. move towards static or extern "c" functions
  3. move towards static member functions

Change History (2)

comment:1 Changed 11 years ago by epruesse

Regarding type-safe callbacks:

  1. Executing a function call that has less arguments than the CB spec is ok in C. It's done a lot e.g. in glib. The surplus arguments end up on the stack and are overwritten, but that doesn't matter.
  2. For type safe C++ callbacks there are libraries, e.g. boost::signal or libsigc++. They are significantly slower than raw C callbacks (libsigc++ seems to be faster than boost::signal), so I don't think it's a good idea for DB interaction. But for GUI callbacks it should be ok.

What do you guys think? Use libsigc++ in WINDOW?

comment:2 Changed 11 years ago by westram

I don't see the point.. is anything broken?

Note: See TracTickets for help on using tickets.