CppCon 2014: Lisa Lippincott 'How to call C libraries from C++'

preview_player
Показать описание

--
Many libraries used by C++ programs present C-like interfaces that are compatible with C++, but are not directly compatible with good C++ style. Using these libraries directly is error-prone in many of the ways C++ is designed to avoid. It is better to pass through an interface layer that presents good C++ style on the C++ side.

But writing such an interface layer is daunting. Completing it may be an enormous task, as are documenting it and maintaining it as the underlying library evolves. To address this problem, I will present a style of writing such interfaces that can be used incrementally as needed, and that reduces documentation cost. I will also present a small library that supports the writing of interface layers in this style.
--
Lisa Lippincott is Chief Software Architect at Tanium, a bay-area startup. Her claim to fame is writing one phrase appearing in the C++ standard. In her spare time, she studies mathematical logic with a category-theoretic approach.
--

*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Write a reactor or event loop, insert sockets into it, hand them over for processing wherever you want. (threads, processes, etc.)

AstralSorm
Автор

the topic is a very important topic in programming computers.

annaoaulinovna
Автор

Oh, great ! Public domain ! Thank you very much ! I'm gonna test this as soon as I can :-) !

germinolegrand
Автор

Oh and of course do provide straight select() when wrapping.

AstralSorm
Автор

I would only consider doing this if I were designing a cross-platform networking library for C++. She is acting like we are wrapping a the sockets API for another language like Rust. If you are using the sockets API from C++ in an application, you would be better off using the sockets API directly, wrapped in a domain specific interface. If you compare the C++ code at 21:04 to the code at 1:00, you will notice that it is pretty much the same even with the unnecessary exception handling code she likely added to make it seem worse. All this accomplishes for application development is producing more code that will need to be maintained. That being said, she gives valid design tips for wrapping a C library if your goal is to provide a cross-platform C++ abstraction of similar platform-dependent APIs.

rationalcoder