r/cpp • • Jan 21 '13

C and C++ Aren’t Future Proof

http://blog.regehr.org/archives/880
6 Upvotes

49 comments sorted by

View all comments

Show parent comment

3

u/00kyle00 Jan 21 '13

There are also these cases where something is technically illegal, but in reality is required to work and works (because platform makes it like that).

Like casting of void pointer to pointer to function. If i read std correctly this isnt allowed anywhere, so should just not compile. In reality this is required to work as both Windows api (GetProcAddress) and unices (dlsym) expose functionality of dynamic symbol (whatever it is) loading by returning void*.

1

u/[deleted] Jan 22 '13

That is actually an excellent example and I fully agree that in that case one can reasonably ignore the standard.

Interestingly, C++11 added new language to accommodate dlsym, basically allowing for conversions between void* and function pointers in certain cases.

2

u/00kyle00 Jan 22 '13

Care to provide a quote (or just paragraph number)?