5 ms·
This works so long as entire build is your own code. Once you get to libraries written by someone else who happens to have a different “wish list”, I would gues
by harikb 7y ago
This works so long as entire build is your own code. Once you get to libraries written by someone else who happens to have a different “wish list”, I would guess this flags idea wouldn’t work well.
- falcor84 7y agoCould you please explain more about the process you're using? Are you compiling external dependencies as an integral part of building your own code?
- derefr 7y agoThey’re using some header-only libraries, presumably. Which, after all, is one of the only unique benefits of C++ that would lead you to choose it for a green-field project over, say, Rust. Header-only template libs + link-time WPO = inlining of template-instantiated monomorphized methods to their type-strict callers. This is the feature that leads e.g. LLVM to be written in C++.
- steveklabnik 7y agoRust doesn’t have headers, but can still do this.
- CreRecombinase 7y agoAnything in your headers is (more or less equivalent to being) copy-pasted into your own code. Many dependencies are header-only (which is the only option I'm aware of if the code is templated).
- petters 7y agoThis is the only sane way of using C++. All C++ dependencies in the same repo, because there is no standard C++ ABI. I am compiling my C++ codebase with gcc, clang, emscripten to wasm, visual studio. Impossible if all dependencies are not present in a "third-party" folder. Google's Abseil library is intended to be used this way. Otherwise, use the C ABI between dependencies.
- gpderetta 7y ago> standard C++ ABI. All major OS have a standard, very stable C++ ABI. Some of them also guarantee a stable ABI for the library components. Of course you cannot use a library built for, say, Windows on Linux but that's true for all languages.
- jdsully 7y agoFor windows that is a very recent change. The ABI used to change with every compiler rev. Further without buyin from the actual standard there’s no gurantee a breaking change won’t be forced by the standard at some point.
- pjmlp 7y agoNot for libraries exposed as DLL or COM. Although one might argue that is only a C++ subset.
- jdsully 7y agoCOM is based off of the C ABI not C++. This was done specifically because C++ does not have a stable ABI.
- pjmlp 7y agoThere is no such thing as C ABI, rather Windows ABI, which you can even select several calling conventions, including Pascal based one. COM is based on the way Visual C++ lays out the VMT, and only masochists use it from bare bones C.
- int_19h 7y agoC ABI is basically structs + functions + function pointers. On Win32, functions and function pointers includes calling conventions, but that's not really important. COM is a C ABI in a sense that its spec defines everything in these terms. Yes, in practice it translates nicely to C++ vtables, but the stability guarantees are defined on the lower level.
- 0xffff2 7y agoIt's just another standard option. Do libraries that are compiled with std=c++14 work with application code compiled with std=c++11? What about the other direction? (I don't actually know because I do build everything from source.) You would basically just be adding a new `std=good` option.
- asveikau 7y agoI have seen with clang++ that if I mix and match .o files built with -std=c++11 and -std=c++17 [something I have occasionally done by accident] and they reference the same classes, sometimes they fail to link, not due to standard library types differing but ones I defined myself that can compile with either standard.
- CJefferson 7y agoThe problem with c++ is many libraries are mostly header files, and they are combined with your code basically by cut+paste, so you can't rewlly seperwte libraries from your own code usefully.