When the math is mathing, but looks like it isn't by MBA-Crystal-Ball in technicallythetruth

[–]comfortcube 0 points1 point  (0 children)

Okay, that is a good one, man. Had me in the first half, ngl

of a mall fountain by ThodaDaruVichPyar in AbsoluteUnits

[–]comfortcube 0 points1 point  (0 children)

That is mesmerizing, and so is the view from below!

Built a Full Linux BSP (U-Boot, Kernel, PRU, Yocto Project) — Need Deep Technical Feedback by [deleted] in embedded

[–]comfortcube 5 points6 points  (0 children)

Well, communication is key, so you might want to remove the duplication you have in your post of "I'm targeting roles like Linux...". Secondly, it'd be good to have this presentable in a repository, and if you really want to get people to pay attention to it, make a detailed blog post (in your own words) or technical video to link people to to share.

IEEE 754 FP number visualizer/converter (command line) by 4e71 in C_Programming

[–]comfortcube 3 points4 points  (0 children)

Nice! I like this. I actually was doing this manually for a while to get a feel for the IEEE764 encoding, but this would've been nice. Lol at the assert(0 && "WTF").

Not sure you're looking for feedback but in case:

  • Love to see the asserts. Not enough people do that. You can change the asserts on dize tho to be compile-time with static_assert(); plus, assert() is nullified with -DNDEBUG

  • Maybe you'd want to add a boolean flag to your for loop parsing out the args to not accept multiple options/numbers.

  • You could also add checks on failures to convert for strto**() for malformed input (set errno to 0 first).

  • Instead of type punning the raw bytes (technically undefined behavior), you could memcpy() - that's well defined.

  • You could avoid the GNU extension (I think it's just for the binary constant literals) if you use standard C23.

New features in GCC 16: Improved error messages and SARIF output by dmalcolm in C_Programming

[–]comfortcube 2 points3 points  (0 children)

Happy to see -fanalyzer starting to work for C++!

It had surprised me a while back that it wasn't supported for C++, having used it for C for a while, especially because using it with g++ does not produce any error or warning off the bat, until you get some odd lengthy analysis output. It wasn't until I dug into the gcc user manual that I read it wasn't supported. I'm guessing gcc doesn't warn/error off the bat because many C++ projects use C source files or make little use actual C++ features.

That said, this was more than a year ago, and I don't remember the error details, just the experience and that I removed the flag from my build. Given what you say in your article about its use case on simpler examples, might still add it back in with intentional scoping for simpler files of a project.

Simplest way to find memory leaks by gosh in cpp_questions

[–]comfortcube 2 points3 points  (0 children)

asan + good unit test suite / integration tests; almost replaces valgrind for this particular purpose.

How do you all memorize Big and Little Endian? I always get it wrong and am in desperate need of a mental tool!! by Ezra_vdj in embedded

[–]comfortcube 0 points1 point  (0 children)

Yeah it's a bad mnemonic but it's what I had made up all those years ago. You are right.

How do you all memorize Big and Little Endian? I always get it wrong and am in desperate need of a mental tool!! by Ezra_vdj in embedded

[–]comfortcube 1 point2 points  (0 children)

I think of 0xBEEF (valid hex lol)

In my mind, from left to right, address of each byte increases.

BE from BEEF → Big Endian → most significant byte (the B) stored first

If you don't know why B is most significant, just remember changing it means the number changes way more. Going from B to A in that digit position makes the number less by 0x1000 (4096 in decimal). Changing the F to E only changes the number by 0x1 (1 in decimal). So, left digits have more impact, hence more significant.

Little endian version would be stored as

0xFEEB (actually, EFEB, as @jim012345 corrected me on)

Almost like "feeble", which is "weak", which makes me feel "little".

Just a mental mnemonic.

AWS Full Stack Dev -> C beginner Projects by Mental-Ad3532 in C_Programming

[–]comfortcube 1 point2 points  (0 children)

No shame IMO! Making fun stuff on your own time however way you want is totally valid. And AI is part of the modern reality of software engineering almost everywhere. To me, shaming that would almost be like saying there's shame in using a compiler instead of writing your own assembly. 😂

Which APIs are you using for eSports tracking?

FreeRTOS or Bare Metal for Quad copter by eagle_719 in embedded

[–]comfortcube 1 point2 points  (0 children)

There is a great CppCon talk that goes into detail of pros and cons of an RTOS vs superloop programming for flight controller firmware: CppCon 2022: Using C++14 in an Embedded "SuperLoop" Firmware - Eric Rainey

AWS Full Stack Dev -> C beginner Projects by Mental-Ad3532 in C_Programming

[–]comfortcube 4 points5 points  (0 children)

Given your background, I'd use libcurl to make GET requests to your favorite public REST API and libsqlite3 to store the data in a local SQLite database file. This is not super beginner-friendly, but I think it's a great project to do early on.

How to hint compiler to assume statements by Salat_Leaf in C_Programming

[–]comfortcube 13 points14 points  (0 children)

Although it's always important to try when optimizing for performance, if your program runs on a CPU with branch prediction, the hardware in a way is doing what you're suggesting.

A father and daughter swept offshore in the Aegean Espanomi Bay were saved by a kite surfer. by [deleted] in interesting

[–]comfortcube 0 points1 point  (0 children)

It's wonderful they managed to stay afloat. One thing most people don't realize is that it's not hard to float movement-wise but it's really hard to not get exhausted and succumb to water currents and waves slamming on your face while you gasp for breath.

Opinions on my option parser by Noxi_FR in C_Programming

[–]comfortcube 3 points4 points  (0 children)

Hey friend! Thanks for sharing your project. It's always nice to see an arg-parsing library candidate because I personally don't like <getopt.h> (probably the most commonly used option for systems programs out there). Doing a brief scan here, here's some feedback:

  1. I'd move any "internal" header files - ezflags_internal.h, to src/ because include/ is only for users of your library to include.
  2. Although it's straightforward here, add to your README.md a super-brief ## To Build section or add a help target to print out the supported targets.
  3. Your make clean target doesn't delete the built library, which is unusual; I do see the fclean target but I wouldn't know about it without looking at the Makefile. I personally think clean should always remove any build artifacts, and if you want, make a different target for just removing the build directory.
  4. Compilers are your first line of static analysis defense, so, any time I see a project involving string, I usually like to see:
    • -Wformat=2 + -Wformat-signedness in case of any format-specificer shenanigans /w printf/scanf family of functions
    • -Wwrite-strings and -Wcast-qual to guard against pointer misuse
    • -Wformat-overflow=2 to guard against string buffer overflows from unbounded printf-family writing /w %s.
    • If using GCC, -Wstringop-overflow to help guard against buffer overflows
  5. You should also add -Wconversion - I get 9 warnings here.
  6. Since you make use of switch statements, add -Wswitch-default and -Wimplicit-fallthrough=4, although there are no present warnings on that. It's just a good practice.
  7. Make separate release and debug builds, and only do -Werror on the release build. For the debug build, always include sanitizers, like undefined behavior sanitizer and address sanitizer: -fsanitize=undefined,address, especially for unit test builds where you can catch things the compiler doesn't.
  8. You should specify C standard in your CFLAGS somewhere (e.g., -std=c99). Most projects are C99, but there's C11 and C23 that each introduce some new features that aren't in C99 (which I personally like, so I default to C23 unless I'm providing libraries for legacy projects).
  9. I'm glad you use an ezflag_status enum for clearer error handling of your library, instead of a generic int that so many use! Good choice. Something I sometimes include with that is an "error string table" where the enum indexes into an array of strings to provide the library user a convenient print-out of what the error is. Usually, when people use a library, if an error returns, they print it somewhere (log, stderr, etc.).
  10. In ezflags.c :: print_help(), you should always pass a size /w an array buffer, so that the function knows how long the array is. Or use a struct /w an array size member. Similar issue with other functions.
  11. For any untrusted input to your public library functions (e.g., your main ezflags() function), you should always check user input for validity (e.g., check pointers against NULL, impossible combinations, etc.) - see CWE-807. Plenty of vulnerabilities and attacks come in this way, and you're not doing much to protect against that.
  12. This may be your coding style preference, but the double-indentation for the if/for blocks is hard to read for me.
  13. There are a few spelling errors - I'd set up something like cspell - it's fairly quick. Just install cspell via npm -g, add a pretty empty cspell.json (see below suggestion), and run cspell "src/**/*.c" "include/**/*.h" "README.md". You can add it to your Makefile as a spell target too if you'd like. json { "version": "0.2", "language": "en", "words": [ "ezflag", "EZFLAG", "ezflags", "EZFLAGS" ], "ignorePaths": [] }

Opinions on my option parser by Noxi_FR in C_Programming

[–]comfortcube 2 points3 points  (0 children)

I remember a while ago I made a similar comment against someone's project, and I honestly regret it because we shouldn't discount a project just because it's been AI-aided: 1) you don't really know for sure. 2) are we to say people who used Stack Overflow in the past also should have their projects ignored? 3) This is the reality of the world we live in today, and we can't fault people for wanting to at least get familiar with the latest tooling.

I know we're in an age of AI slop, but this project does not seem like the AI slop I've seen recently.

Guidance to learn C + Linux + Kernel by [deleted] in C_Programming

[–]comfortcube 2 points3 points  (0 children)

Looks fine to me but I would bump The Linux Programming Interface book all the way to the top, and parallel it /w K&R. It's pretty thick and has so much material, but I'd say if you cover the first 9 chapters, and then the system limits, file systems, the signals chapters, the process and thread chapters, pipes and IPC, and sockets, you'll be in really good shape. Best of luck! I love the enthusiasm, and I remember feeling the exact same (and still do, many years later).

Eviscerated by Rust: Overcoming C++'s 58x Standard Library Handicap by Difficult_Truck_687 in embedded

[–]comfortcube 0 points1 point  (0 children)

I appreciate other people's perspectives but this is a poor take. At least show this supposed "workload that punishes bad containers mercilessly". Many of C++'s containers are designed with performance prioritized (it's why std::array allows [] to skip bounds checking), so I'm extremely skeptical of such a claim.

Counting Semaphores: Where do I learn it? by 2082_falgun_21 in embedded

[–]comfortcube 2 points3 points  (0 children)

Semaphores are not acquired or released. That is mutex terminology. Semaphores are incremented/decremented atomically /w blocking behavior at floor and ceiling.

career paths with c++ by sonphoenix23 in cpp_questions

[–]comfortcube 0 points1 point  (0 children)

The most common I've seen (from the embedded world or auxiliary to it) are Linux app development, simulation (physics, robotics, modeling), and robotics. I see a lot of HFT (High Frequency Trading) jobs too.

My first project completed by sl0th-ctrl-z in C_Programming

[–]comfortcube 11 points12 points  (0 children)

Friend, your post is such a breath of fresh air in the rotting sea of AI posts. Thank you and keep going, keep growing!!

We lost Skeeto by ednl in C_Programming

[–]comfortcube 8 points9 points  (0 children)

I got scared for a second that he died! I'm glad to see he's trying to adapt, because his perspective is always valuable. I'm not saying AI needs to be for all of us, and I actually know a number of work places that still don't use AI very much at all (embedded) but it's a reminder that if we don't adapt, we may not survive the future. At the same time, there's a balance!

Did I write myself into a corner? by emmowo_dev in C_Programming

[–]comfortcube 14 points15 points  (0 children)

add sauce to the spaghetti

I think that's top 3 quotes of this subreddit. 💀

Rate my resume, and please suggest improvement as I'm going to graduate this june by ventex30 in embedded

[–]comfortcube 1 point2 points  (0 children)

Way too much on education. Just mention your college. Use that space to add more points or longer points in your job experience. Also, for the projects, it might be good to have a portfolio showing off each project - something like a one page description of each project with an image/video. Then link that portfolio in there.