Re: Replacing old C-style casts with static|reinterpret_cast?



Den 2017-05-20 kl. 11:51, skrev Kjell Ahlstedt:
Den 2017-05-19 kl. 17:04, skrev Daniel Boles:
Murray and Kjell: Any thoughts on the prospect of replacing C style casts with reinterpret_cast where appropriate? Chiefly, when converting between opaque (and thus not static_castable, and also probably breaking aliasing rules...) pointers to GObjects at different levels of the inheritance hierarchy.

I did prepare a patch doing this for master, which I think covered all or most instances, and compiled - and can't foresee any possible issues - but obviously discussion is needed (and my foresight is not exactly renowned).

If this works, then it would be another nice C++ification to see throughout the codebase.

Cheers!
Daniel

reinterpret_cast is already used for conversion between different levels of the GObject inheritance hierarchy, e.g. in the gobj() methods generated by _CLASS_GOBJECT, _CLASS_INTERFACE and _CLASS_GTKOBJECT. But it's not used consistently in other situations. I see no harm in using it consistently.

Kjell
Clarification: reinterpret_cast is not used consistently in other situations for conversion between different levels of the GObject inheritance hierarchy. I'm in favor of reinterpret_cast for such conversions. Other conversions should be judged separately from case to case. And static_cast or dynamic_cast is preferable where applicable.

Kjell


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]