Skip to content

Best practices for mixed C and C++ #10106

Answered by eli-schwartz
lb90 asked this question in Q&A
Discussion options

You must be logged in to vote
  • meson supports adding both C and C++ sources to the same library or executable, and will by default use the C++ driver to link with. There is a link_language kwarg to override this.
  • both the cc and cxx compilers will exist (be searched for, declared as languages for files each needs to compile). The get_compiler() function merely gives you a handle to that compiler. In many cases, it doesn't matter which one you use since e.g. find_library() finds the same libraries in either case and C++ shared libraries are technically linkable by the C compiler because they might provide a C ABI (but you can't really know until you try). Depending on your use case, though, you absolutely do need to us…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
4 replies
@lb90
Comment options

@xclaesse
Comment options

@xclaesse
Comment options

@eli-schwartz
Comment options

Answer selected by lb90
Comment options

You must be logged in to vote
4 replies
@eli-schwartz
Comment options

@afud
Comment options

@eli-schwartz
Comment options

@afud
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants