▲ 0 r/cpp

Catch2 Sucks

I sure do love waiting 5 minutes on my laptop waiting for tests to compile, even on -o0.
It is really a productive use of my time.

This is with Catch2 v3, with prebuilt binary packages, it is that slow.
Honestly gtest is older but compiles way way faster.

Please stop using that.

reddit.com
u/TheRavagerSw — 2 days ago

I'm very confused about styling and naming conventions

Basically every library has their own coding style.

Everyone uses different extensions for some reason, see .h, .hpp, .hh for header files, .cc .cpp .C for sources , .cppm and .ixx for module interfaces etc.

Everyone uses different naming conventions, STL uses snake_case with _type suffix for classes sometimes _t and sometimes nothing. Google uses CamelCase etc.

It seems to me no majority consensus has emerged, and it really hurts even thinking about these things before you write your own code. As each dependency you use has a different coding style.

How do people even solve it? Is there a hidden style guide that everyone uses that I don't know. core guidelines isn't really a style guide in the purest sense.

reddit.com
u/TheRavagerSw — 8 days ago
▲ 0 r/cpp

GCC Build Experience

Firstly, you need a native installation of g++ and binutils via your package manager, then you need sysroots for your target platforms(probably x64 glibc linux and arm64 glibc linux).

The workflow goes like this, to cross compile GCC itself to run on another arch, in my example from arm64 binary targeting x64 you follow this build order. I'm assuming an x64 system

x64 binutils -> x64 gcc -> arm bintutils(--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu) -> gcc (x64->arm64) -> binutils(arm64->arm64) -> gcc(arm64->arm64) -> bintutils(arm64->x64) -> gcc(arm64->x64)

Now a couple of rules, pass --with-build-sysroot when building a normal compiler such as x64 -> x64 and pass --with-sysroot when building a cross, your toolchain flags won't matter at all in the eyes of GCC autoconf script.

You need to embed flags into env vars like CC to make sure stuff passes sometimes, it is actually quite verbose, you do the same thing at CC, CC_FOR_BUILD, CFLAGS AND CFLAGS_FOR_BUILD.

I recommend disabling multilib,gdb,werror and lto and always disabling bootsrap, you can do those but I don't recommend it.

You have to pass -Wl,--undefined-version if you use lld rather than ld. Otherwise your build will fail.

Here is an example toolchain I used to compile a arm64 -> x64 compiler in my x64 host

BUILD_SYSROOT=/home/mccakit/dev/sdk/debian-12-x64
HOST_SYSROOT=/home/mccakit/dev/sdk/debian-12-arm64
TARGET_SYSROOT=/home/mccakit/dev/sdk/debian-12-x64
BUILD_GCC_BIN=/home/mccakit/dev/compilers/gcc/linux-glibc-x64/bin
HOST_GCC_BIN=/home/mccakit/dev/compilers/gcc/linux-glibc-arm64/bin
TARGET_GCC_BIN=/home/mccakit/dev/compilers/gcc/linux-glibc-x64/bin
BUILD_BINUTILS_BIN=/home/mccakit/dev/compilers/binutils/linux-glibc-x64/bin
HOST_BINUTILS_BIN=/home/mccakit/dev/compilers/binutils/linux-glibc-arm64/bin
TARGET_BINUTILS_BIN=/home/mccakit/dev/compilers/binutils/linux-glibc-x64/bin
LLVM_BIN=/home/mccakit/dev/compilers/llvm/bin
CCACHE=/home/mccakit/dev/tooling/ccache/bin/ccache
export CC="${CCACHE} ${HOST_GCC_BIN}/aarch64-linux-gnu-gcc -B${HOST_BINUTILS_BIN} -B${LLVM_BIN} --sysroot=${HOST_SYSROOT} -Os -DNDEBUG -w -ffunction-sections -fdata-sections -fuse-ld=lld -Wl,--gc-sections -Wl,--undefined-version"
export CXX="${CCACHE} ${HOST_GCC_BIN}/aarch64-linux-gnu-g++ -B${HOST_BINUTILS_BIN} -B${LLVM_BIN} --sysroot=${HOST_SYSROOT} -Os -DNDEBUG -w -ffunction-sections -fdata-sections -fuse-ld=lld -Wl,--gc-sections -Wl,--undefined-version"
export AR="${HOST_BINUTILS_BIN}/aarch64-linux-gnu-ar"
export NM="${HOST_BINUTILS_BIN}/aarch64-linux-gnu-nm"
export RANLIB="${HOST_BINUTILS_BIN}/aarch64-linux-gnu-ranlib"
export AS="${HOST_BINUTILS_BIN}/aarch64-linux-gnu-as"
export STRIP="${HOST_BINUTILS_BIN}/aarch64-linux-gnu-strip"
export CFLAGS="-Os -DNDEBUG -w -ffunction-sections -fdata-sections"
export CXXFLAGS="-Os -DNDEBUG -w -ffunction-sections -fdata-sections"
export LDFLAGS="-fuse-ld=lld -Wl,--gc-sections -Wl,--undefined-version"
export CC_FOR_BUILD="${CCACHE} ${BUILD_GCC_BIN}/gcc -B${BUILD_BINUTILS_BIN} -B${LLVM_BIN} --sysroot=${BUILD_SYSROOT} -Os -DNDEBUG -w -ffunction-sections -fdata-sections -fuse-ld=lld -Wl,--gc-sections -Wl,--undefined-version"
export CXX_FOR_BUILD="${CCACHE} ${BUILD_GCC_BIN}/g++ -B${BUILD_BINUTILS_BIN} -B${LLVM_BIN} --sysroot=${BUILD_SYSROOT} -Os -DNDEBUG -w -ffunction-sections -fdata-sections -fuse-ld=lld -Wl,--gc-sections -Wl,--undefined-version"
export AS_FOR_BUILD="${BUILD_BINUTILS_BIN}/as"
export AR_FOR_BUILD="${BUILD_BINUTILS_BIN}/ar"
export RANLIB_FOR_BUILD="${BUILD_BINUTILS_BIN}/ranlib"
export NM_FOR_BUILD="${BUILD_BINUTILS_BIN}/nm"
export CFLAGS_FOR_BUILD="-Os -DNDEBUG -w -ffunction-sections -fdata-sections"
export CXXFLAGS_FOR_BUILD="-Os -DNDEBUG -w -ffunction-sections -fdata-sections"
export LDFLAGS_FOR_BUILD="-fuse-ld=lld -Wl,--gc-sections -Wl,--undefined-version"
export CC_FOR_TARGET="${CCACHE} ${TARGET_GCC_BIN}/gcc -B${TARGET_BINUTILS_BIN} -B${LLVM_BIN} --sysroot=${TARGET_SYSROOT} -Os -DNDEBUG -fPIC -w -ffunction-sections -fdata-sections -fuse-ld=lld -Wl,--gc-sections -Wl,--undefined-version"
export CXX_FOR_TARGET="${CCACHE} ${TARGET_GCC_BIN}/g++ -B${TARGET_BINUTILS_BIN} -B${LLVM_BIN} --sysroot=${TARGET_SYSROOT} -Os -DNDEBUG -fPIC -w -ffunction-sections -fdata-sections -fuse-ld=lld -Wl,--gc-sections -Wl,--undefined-version"
export AR_FOR_TARGET="${TARGET_BINUTILS_BIN}/ar"
export NM_FOR_TARGET="${TARGET_BINUTILS_BIN}/nm"
export RANLIB_FOR_TARGET="${TARGET_BINUTILS_BIN}/ranlib"
export AS_FOR_TARGET="${TARGET_BINUTILS_BIN}/as"
export CFLAGS_FOR_TARGET="-Os -DNDEBUG -fPIC -w -ffunction-sections -fdata-sections"
export CXXFLAGS_FOR_TARGET="-Os -DNDEBUG -fPIC -w -ffunction-sections -fdata-sections"
export LDFLAGS_FOR_TARGET="-fuse-ld=lld -Wl,--undefined-version"
export PATH="${BUILD_BINUTILS_BIN}:${BUILD_GCC_BIN}:${HOST_BINUTILS_BIN}:${HOST_GCC_BIN}:${PATH}"

Final Result

root@24a3b7f889f7:/tmp# uname -m
aarch64
root@24a3b7f889f7:/tmp# 
root@24a3b7f889f7:/tmp# x86_64-linux-gnu-g++ -B/mccakit/binutils-x64/bin --sysroot=/mccakit/debian-12-x64 hi.cc -o hi_x64
root@24a3b7f889f7:/tmp# ls /mccakit/
binutils-arm64	binutils-x64  debian-12-x64  gcc-arm64	gcc-x64
root@24a3b7f889f7:/tmp# 
mccakit@mccakit-pc:~/desktop$ sudo ./x64_bin 
[sudo] password for mccakit:           
hello world
mccakit@mccakit-pc:~/desktop$ 

Here are the prebuilt GCC binaries for lazy folks https://github.com/mccakit/prebuilt_gcc

Conclusion: Use clang, honestly I don't recommend gcc unless you have to. It is easier to build and run.

u/TheRavagerSw — 10 days ago
▲ 16 r/cpp

GCC should ship prebuilt binary tarballs like LLVM

It is really annoying, when you wanna test something you can't just download a previous release like llvm, so it is very hard to check if there is a regression.

Also, the default build of c and c++ only, takes like an hour because of triple consecutive builds. So every time you have to lookup to that weird flag on the internet to turn that off.

reddit.com
u/TheRavagerSw — 12 days ago

Which subfields in C++ development are actually in demand?

I'm kinda lost on the career side of things.
I'm an EE graduate specializing in C++ development, control theory and general electronic design.

I always thought I would go into embedded, and then job hop to a lucrative career. Even though I always wanted to work in big productivity apps like Zbrush, Nuke or Substance Painter.

But I'm not certain now, I'm not certain if market even values my skills.

So, if anyone can inform me about the career trajectory of C++ subfields I would be grateful, such as "I went to trading and work conditions are like this, people in my field earn between X and Y"
I really want to at least have some idea what to do rather than go blindfold, apply everything and accept the first offer without question

Thanks in advance

reddit.com
u/TheRavagerSw — 15 days ago

How should I proceed as an EE graduate?

I don't know how to proceed my career after graduating, previously I hoped specializing in an useful subfield would result in a lucrative career where I job hop often to make money.

Let me talk about myself, I'm an EE graduate specializing in Control Theory and C++ development. I'm also proficient in many other areas of engineering work, such as creating and serving presentations, writing reports and visualizing data, 2D CAD, PCB design and general electronics work such as soldering.

What can I do with my skillset to earn good money?
What EE subfields are actually in demand and match with my skillset?
Where can I look for jobs besides linkedin

I'm gonna add my resume as a comment if I can

reddit.com
u/TheRavagerSw — 15 days ago

Why runtime performance of C++ modules increase so much with lto?

I was porting libfmt to native C++ modules recently, It had tons of macros related to forced inlining, so I removed them and saw a %10 performance reduction, then I removed all in lines in module interfaces and performance was identical when both the original library was built with Lto and my own.

The weird part is, Overall performance increased when I removed inline and applied lto, compared to inline and lto

Why is that? Something about how compilers deal with C++ modules?

reddit.com
u/TheRavagerSw — 16 days ago
▲ 24 r/cpp

Common Problems I see with Public Libraries Build Scripts

Hi, I'm an early user of Common Package Specification and C++ modules. I package and port libraries for my own use frequently.

I want to talk about issues I see constantly.

- Having specific options for sanitizers, exceptions etc, this is a toolchain problem, if I wanna build your library with sanitizers I can just add the flags to my cmake toolchain file same as allocators.

- Not separating build options to a separate file, meson already does this, it ain't that hard to do in cmake, just cache variables in a separate file at project dir which you include before subdirs

- Making tests separate cmake projects rather than just executables, just why?

- Vendoring dependencies, copy pasting files from other projects rather than just consuming these external libs via packages.

- Using unnecessary helper functions that really makes the cmake script unreadable. Build scripts don't need to be over engineered, they are just basic scripts in which you define very basic information.

I could go on but I'm tired.

reddit.com
u/TheRavagerSw — 17 days ago
▲ 92 r/cpp

I really reconsider my life choices when I have to deal tooling bugs.

I like writing useful stuff, I'm tired of fighting tooling, I can legit say %80 percent of my time goes to dealing with dependencies build systems etc. Very rarely I have the privilege of actually writing stuff.

This shit sucks, like it really sucks. I hate it.

Is this normal, or only people who have it easy are web Devs and Java Devs since they are in a sandboxes environment and don't have deployment problems.

Am I crazy or is this common?

reddit.com
u/TheRavagerSw — 1 month ago
▲ 4 r/cpp

Can windows devs provide us with a visual studio sdk in a tarball/zip form?

Currently, in order to cross compile to windows properly we either download visual studio in a windows machine, copy it's contents to our machine and pass /winsysroot to clang-cl or it's equilevent gnu flag.

Or we use msvc wine to download using wine and deal with capitalization issues.

Why can't windows devs provide us with something similar to msvc wine? It would really simplify getting sysroots to setting up your toolchain.

I filed a ticked to but didn't heard a reply. If anyone here can raise awareness on this issue it would help the whole community.

reddit.com
u/TheRavagerSw — 2 months ago

I feel regret after graduation

EE, All my life for the last 4 years was about getting that piece of paper and 2 years before that was getting there.There is nothing impressive about getting bullied by professor's, spending your free time on internship searching and spending your summers on internships.

I don't feel happy at all, my body is a wreck, my mind more so. I don't have stable routines nor do I meet new people on the regular. My love life is an utter disaster.

I have to rebuild, something that shouldn't have been broken in the first place. I really want to forget all my undergraduate years.

reddit.com
u/TheRavagerSw — 2 months ago
▲ 0 r/cpp

What is the point of Emscripten?

Lately I was writing a manual for building my development environment incase I need to build it again.

​

I look at the platforms I want to target, and see Emscripten, for wasm32 and wasm64. Lately, I saw an article, saying that all major browsers have supported wasm64 besides safari, and I don't care about Mac users so I thought why don't I just target wasm64, I don't really want to think about going over 4GB anyway.

​

The problem is, I really want to get to multi language language projects, and rust doesn't have an Emscripten backend for 64 bits. It has one for 32 bits only.

​

That got me thinking, why am I even doing this, why should anyone run compute intensive stuff from a browser rather than just downloading a binary. I really feel like it doesn't really solve real problems.

​

Most stuff that people ported to web via emscripten is disgustingly slow, and they have zero toolchain control unlike native development. I can't just build a standard library of my choice from source and use it. Neither can I just use another allocator. It is all a giant black box.

​

I mean, android development is also annoying, but libraries like SDL just give you the wrappers normally, and the way you build stuff makes sense, you build C/C++ parts normally and just run another build on top of that with gradle and friends.

​

​

reddit.com
u/TheRavagerSw — 2 months ago
▲ 50 r/cpp

Projects being in "Show and Tell" is bad.

Because of this, nearly all posts are just conference links and blog links. Projects deserve their own post and are the source of actual fun discussion. I propose that the Show and Tell rule be removed, but Show and Tell post can remain if a project that lame appears.

reddit.com
u/TheRavagerSw — 2 months ago

Unless you are designing stuff from scratch without any external components.

Any design involves digital and analog IC's. First of all in spice you can't have digital decoder interacting with an op amp for example.

Also, even for purely analog designs, when external IC's enter into picture the result is completely unreliable.

Either every company agrees on distribution format that would allow them to ship actual IC models rather than the shit they ship now I don't see a reason to do analog design via spice simulators.

Same goes for digital ICs, unless we can actually mix them into stuff I see no reason to actually use SPICE.

In its current state it is utterly worthless for most people. Who don't build stuff from scratch.

reddit.com
u/TheRavagerSw — 4 months ago

Rust generates documentation in one format, C++ with another, Zig in some other form. Manual documentation is also uses varying formats.

And at the end, you need an interactive document with a search bar and links etc, most importantly all your generated stuff need to match with your manual doc.

You can't have C++ API use one font and one theme and the rust API in another.

First of all, I think HTML is the end result, I wish we had something like pdf for it but we don't.

So I have 2 questions:

- What is intermediate format that generates html and is standard?

- How to process C++ sources with an parser based solution to that intermediate format?

So the idea is I have a compilation database and I generate API ref with clang doc, it has a MD backend, an HTMl backend a YAML backend and a JSON backend. How do I go from these to something like asciidoc or restructured text or any other language that can output a document with a search bar and theme?

Same with other languages like how do libraries that deal with bindings deal with it?

reddit.com
u/TheRavagerSw — 4 months ago

For a long while I used sphinx+ breathe + doxygen for API ref sites. The problem I face is sphinx is a python dependency, and I don't like being dependent on it.

Also, with modules there isn't a clear interface file, clean design is with a single, providing both implementation and interface. So just scanning a file doesn't work.

The obvious answer is clang-doc, but is has several issues:

\- HTML doesn't have a search bar

\- MD output doesn't have tables for stuff like enum classes.

So, what to do exactly? I'm kinda lost to be honest.

reddit.com
u/TheRavagerSw — 4 months ago

My dislike comes from the point he is venerated as a saint in eastern orthodox church.

He murdered his son, his wife, his father in law, his brother in law and his nephew, who was 11 years old.

He caused the succession system to fail by usurping power after his father's death. Thus causing the death of thousands.

He could have just ruled his own portion after taking over his father's lands but he lusted over power.

He definitely didn't live a saintly life. He isn't a type of person who people should look up to.

He was an ok emperor, but the fact people idolise him makes me fucking angry

reddit.com
u/TheRavagerSw — 4 months ago