r_cpp | Unsorted

Telegram-канал r_cpp - C++ - Reddit

-

Stay up-to-date with everything C++! Content directly fetched from the subreddit just for you. Join our group for discussions : @programminginc Powered by : @r_channels

Subscribe to a channel

C++ - Reddit

I suspect my program is failing because of something to do with library linking not going right, but compilation and linking doesn't give errors. Any ideas how to troubleshoot this?

Long story short, my code compiles without any errors or warnings but my program doesn't start.

I'm using Cmake, and am trying to link the libraries Boost.System and OpenSSL to work with Boost.Asio SSL. I've implemented the 2 necessary src.hpp files in only one source file, set the BOOST\_ASIO\_DYN\_LINK compiler definition, even made sure the OpenSSL libraries are linking before the system library (not sure if that would actually help at all), I've confirmed that Boost::system, OpenSSL::SSL, and OpenSSL::cryptowhatever are being found by CMake, tried using static libraries instead of dynamic, and I tried making my own one-file library that includes the src.hpp files, sdkddkver.h, and nothing else, and every single one of these actions has gotten the same result:

No compile errors. No linking errors. But the program doesn't start. No erorrs other than an exit code of 1.

The reason I'm convinced it's a library error is that's the reason I had an issue with getting a program to start last time too (it was threads & I had to rebuild it as shared. I'm using a pre-built OpenSSL because fuck Windows, but I've just created and built a small file that uses an OpenSSL header file and links the library and confirmed that it does in fact run.

I truly feel out of options and unless there's just some tiny detail I'm totally forgetting to Google, it feels like RTFM is impossible here as I've tried so many combinations and usages of the src.hpp files and compiler definitions Boost.Asio mentioned but hardly elaborated on. Please, if you have any idea what the issue could be, then let me know. I'm going insane but with any luck I'll get some snotty answer that happens to be completely right and makes me sound like an idiot.

https://redd.it/1h3jqsl
@r_cpp

Читать полностью…

C++ - Reddit

Print out all CMake variables during a CMake run
https://a4z.gitlab.io/blog/2024/11/30/Print-all-CMake-variables.html

https://redd.it/1h391oo
@r_cpp

Читать полностью…

C++ - Reddit

MFC resources

Hi guys,
So I have joined a company recently and the product I am working on is a desktop application. I have 2 yoe in C++ but not in MFC and this is completely new to me in this organisation.
I need some good resources on which I can rely on and learn about MFC.
Please do suggest✌️

https://redd.it/1h2sqjw
@r_cpp

Читать полностью…

C++ - Reddit

What types of operations can be handled asynchronously without creating new threads?

I understand that certain operations, like handling external events (e.g., mouse or keyboard presses) and asynchronous I/O, can be managed asynchronously without the need for creating new threads. For example, in the case of I/O, the CPU isn't involved directly, which allows it to be handled in a non-blocking way.

However, when it comes to computationally intensive tasks, it seems like a new thread (or offloading to another process) is required if we want the main thread (e.g., in a GUI application) to remain responsive. For instance, in a single-threaded GUI application, we can handle incoming signals or perform async I/O without freezing the UI, but we would need a new thread to run a heavy computation in the background.

Are there other cases—apart from handling external signals/events and asynchronous I/O—where tasks can be treated asynchronously without the need for new threads? Or is intensive computation always an exception that requires threading or multiprocessing to prevent blocking?

https://redd.it/1h2nnow
@r_cpp

Читать полностью…

C++ - Reddit

I wish to get a certificate in cop any recommendations?



https://redd.it/1h2k78w
@r_cpp

Читать полностью…

C++ - Reddit

🖤 TMS Software Black Friday 2024 Deals 🖤


Curious about our amazing Black Friday offers? Check them out now!
👉 TMS Black Friday Page

⏳ Hurry, these offers are only available for 24 hours! ⏳

https://redd.it/1h2klti
@r_cpp

Читать полностью…

C++ - Reddit

Project Tips

I'm in my 3rd year of uni doing game development, specifically the programming side of it. I've got some experience with C++ and C#, I was just wondering what kind of projects can I be doing in my free time that will teach me a lot more about C++ and will help bulk out my portfolio.

https://redd.it/1h2humo
@r_cpp

Читать полностью…

C++ - Reddit

Working with threads and mutex with C++

I would like some advice on working with mutex and threads in C++, including best practices and safety considerations. Could someone share this information or recommend some good references?

https://redd.it/1h227qs
@r_cpp

Читать полностью…

C++ - Reddit

File scoped namespaces

Might be a stupid question, but I´m gonna ask it anyway.

Has there been any attempt to add file scoped namespaces to cpp (from c#)? I do a lot of c# coding on my day job and think this is a great feature which makes code much more readable.

EDIT:

The idea is that because most of the files in all projects only have a single namespace you can write a namespace declaration somewhere at the top of the file and rest of the file is seen as inside it

namespace A.B.C;
class D {}

https://redd.it/1h1sn8h
@r_cpp

Читать полностью…

C++ - Reddit

Sandor Dargo's Blog - How to ensure a class is not copyable or movable
https://www.sandordargo.com/blog/2024/11/27/non-movable-classes

https://redd.it/1h1sd6e
@r_cpp

Читать полностью…

C++ - Reddit

Why do some people prefer allocating their own application class instead of using static or global variables?

I’ve seen many projects doing this but most of the time they could just have used static member variables or even global ones.

Is it because global variables are messy? Or is it to handle smart pointers better? I’ve never understood the reason why, but I think I might be missing something, therefore I wanna know.

https://redd.it/1h1gkhm
@r_cpp

Читать полностью…

C++ - Reddit

On "Safe" C++
https://izzys.casa/2024/11/on-safe-cxx/

https://redd.it/1h1ca70
@r_cpp

Читать полностью…

C++ - Reddit

Talk on evaluation

Following up on the post on C++ semantics, now devs will dive into compile-time evaluation. Yuri Minaev (yep, same guy) will be talking about using the AST to evaluate values, its pitfalls, and a little about IR.

The website mentions a live session happening on December 5, or the video will be there fyi

https://redd.it/1h153d3
@r_cpp

Читать полностью…

C++ - Reddit

c++ utilities for managing custom 1 billion record HIBP database

The [Have I been pawned](https://haveibeenpwned.com/Passwords) password database is well known, and contains 38GB, of compromised passwords with "hash and leak count" . Either sha1 or ntlm hashes are available. Typical uses include screening compromised passwords during sign up or login, or auditing existing databases of hashes.

An online API is offered from the above website, which uses "k-anonymity" for privacy. In some use cases, a way of locally querying the database may be more appropriate for offline access, to reduce external dependencies, or address remaining security concerns. Traditional databases are awkward to use for this size of dataset and a custom solution seemed warranted.

I have been maintaining internal tools for such use cases, which I have now polished up and am making public:

[https://github.com/oschonrock/hibp](https://github.com/oschonrock/hibp)

Highlights are:

* Generic "flat\_file" class to represent binary format, reducing disk footprint by \~half to 21GB
* compile time intrinsics for vectorised hash comparisons (\`arrcmp\` replaces \`memcmp\`)
* Iterators enable use of many STL algorithms on data (used extensively in utilities)
* High performance downloader using libcurl+libevent: 2 threaded producer / consumer model
* Download fills 1Gb/s pipe with adjustable concurrency > 300, over 1 million "file chunks"
* => \~6minute download for entire db on a modest VM with 1Gb/s connection
* local http server (restinio based) for trivially serving plain, sha1 and ntlm records
* performance, simply using \`std::lower\_bound\` for binary search, achieves 1500 queries/s with 1 thread on very modest CPU and disk hardware.
* "Table of contents" style pre-index can double performance in some hardware configurations
* Most utilities have a tunable sub 10MB memory footprint and may be suited to constrained environments
* Cross platform: Linux, FreeBSD and Windows (mingw) are tested.

Feedback and requests welcome!

https://redd.it/1h1106s
@r_cpp

Читать полностью…

C++ - Reddit

First-hand Account of “The Undefined Behavior Question” Incident
http://tomazos.com/ub_question_incident.pdf

https://redd.it/1h0ximn
@r_cpp

Читать полностью…

C++ - Reddit

Project review : Vehicle Management System

I’ve created a Smart Vehicle Management System using Modern C++ and Object-Oriented Programming concepts!

Check out the full project here:

https://github.com/AtharvShinde/CPP_Vehicle_Management_System

Feel free to review, suggest improvements, and don’t forget to ⭐ the repo if you like it!

https://redd.it/1h3ebu7
@r_cpp

Читать полностью…

C++ - Reddit

Trip Report: Fall ISO C++ Meeting in Wrocław, Poland | think-cell
https://www.think-cell.com/en/career/devblog/trip-report-fall-iso-cpp-meeting-in-wroclaw-poland

https://redd.it/1h33srd
@r_cpp

Читать полностью…

C++ - Reddit

#include <curl/curl.h>

Hello,

I need help about <curl/curl.h> library, I guess it does not come with g++ libraries, so how do i download it from my terminal? (I use windows and vscode)

https://redd.it/1h2qjjc
@r_cpp

Читать полностью…

C++ - Reddit

C++ 20 Modules Template

Hello, over the past week, I've made a C++ template to start a project that uses modules, let me know if you have any suggestions ;)

The repo

https://redd.it/1h2nfon
@r_cpp

Читать полностью…

C++ - Reddit

Applying Modules to Projects That Can't Use Modules

As we know, we can use precompiled std module to speed up the compilation process. But we can't mix (at the moment) modules and includes very well which is problematic when it comes to big established codebases (as seen in https://arewemodulesyet.org/). That said, I found out weird hack (which I'm sure is UB) that might be useful for some projects.

If we break compilation into two steps

* Run the preprocessor only with added -isystem "{}\\std\_empty\_stubs" where std\_empty\_stubs is directory containing empty std headers (with some exceptions)
* Compile the preprocessor output with import std.compat; added at top of the file.

This seems to consistently result in a 20-30% reduction in compile times across MSVC, Clang 19, and GCC 15. So, even if we need to call the compiler twice for each object file it is still faster overall without any source modification.

There are some caveats of course

* We still need to compile std module but it can be reused (and it takes a lot less space than old precompiled headers)
* The project must ensure consistent compiler flag usage across object files, particularly for flags that affect the standard library.
* Many of the projects I've tested this on required additional tweaks to handle standard macros correctly.

I wonder if this approach could be somehow integrated into the compiler itself (something like adding `--implicit-std-module`) so that projects that would never use std modules could still benefit from it.

https://redd.it/1h2ktjz
@r_cpp

Читать полностью…

C++ - Reddit

What's happening with P2500 (parallel algorithms with Senders/ Receivers)?

P2300 (Senders/ Receivers) has been merged into C++26. I was wondering what's happening with P2500. The issue tracker's last update was in 2023.

- is this still actively being worked on?
- if not: what are the alternative proposals?
- is it still on track for C++26?


https://redd.it/1h2jp2b
@r_cpp

Читать полностью…

C++ - Reddit

Should I drop learning and using C++

I am relatively new to this language (around a year) and really like it. Recently I saw a doomer article like this https://herecomesthemoon.net/2024/11/two-factions-of-cpp/ and it made me really sad. I'm too late for the party, right? "Everyone need to switch to rust", "There is no reason to use C++ for new projects, it's a language of old codebases", "The governments wants to stop using C and C++" makes me feel bad, like I'm wasting my life on a bad thing. I'm a STEM student and I hate things like MATLAB and python mainly because of their dynamic type system and performance. I tried to use Rust. But it is unreadable to me, I don't like the overshort syntax(Yes, I do prefer "mutable" to "mut", "string" to "str", "whateverFunctionName" instead of "whtrvrfunmm" that Rust makes use of constantly), I don't like language in general and the extremely repulsive(in my opinion) community which reminds me of a cult or sect. It seems to me that Rust people tend to care more about politics and ideologies than about programming, but maybe this is just my observation and I am completely wrong. (It's also sad to see how angry and polarized people are today, not only in programming) I tried Java and C# (I used them for games when I was in the high school) but they aren't fun to use for me. I dunno. I feel that C++ **is fun** to use for me. Yes I don't like many design choices of the standard library(like mandatory exceptions, there is no way to override the exception behaivour of things like std::array::at or std::basic_string::resize to custom error codes for example). I simply write my own stuff or use a third-party library. I like how powerful the language is and how you are free to do anything. Maybe I am wrong and just too noob to fathom superior and ultra safe and modern languages like Rust, Zig or Go or whatever?

https://redd.it/1h273wf
@r_cpp

Читать полностью…

C++ - Reddit

C++

Need teacher for C++

https://redd.it/1h1zdwz
@r_cpp

Читать полностью…

C++ - Reddit

Hans Wennborg: C++ switch statements under the hood in LLVM
https://youtu.be/nfy51jenN3M

https://redd.it/1h1t37x
@r_cpp

Читать полностью…

C++ - Reddit

Why not unstable ABI?

The standards committee has time and again shown they value ABI stability over all else. And I get why. While there isn’t really anything I’ve worked on where everything can’t be recompiled from source, I do see how beneficial it can be when working with or distributing closed source binaries. Especially binaries from companies that might not exist anymore that provide critical functionality to a wider system.

But I guess I don’t really see why we can’t have both. The GCC standard libs use versioned ABI already. Of course, even with versioned ABI, the memory layouts of class instantiations must remain the same.

But do they really? Or would it just be hard to version, at the ABI level, class definitions too? Would it not be possible to have a flag for each compilation unit that identifies the ABI version used and a link flag indicating the ABI version of a library being linked? The scenario I’m imagining goes like this:

The compiler would use the ABI version to determine which STL implementation to use for that compilation unit.

There would also be a number of conversion methods baked in to translate a class instance from one ABI to another, perhaps embedded with the standard library.

The linker then would use the ABI versions of the object files being linked to determine if an injected interface would need to be made between the two libraries being linked that translates one standard class version to another. If this is needed, the linker would launch the compiler again to compile this quick interface layer.

There is obviously both a runtime and compile time cost here. But in spirit of the pay for what you use, you can always opt to stay on the stable ABI. And this feature would only be used sparingly to fix known standard library performance issues.

This seems like too “simple” of a solution to not have been considered and rejected before. If so, are there any resources on discussions similar to this one? If not what are your thoughts?

https://redd.it/1h1na2i
@r_cpp

Читать полностью…

C++ - Reddit

Rust-lang for HFT's

Me and my brother have started programming for our own Hight Frequency trading firm that we are starting by ourselves.
He is a very senior C++ developer with a lot of experience in the HFT field. I have 3 years of experience in python backend and 1 year of experience recently in Rust (Companu greenfield projects)

While he is making everything in C++ I am allowed to build the same functionality in Rust with him reviewing my implementations for speed tweaks and benchmarking.

I was wondering if the effort of trying out Rust here is futile because while they say both languages are nearly the same I feel that the last nanoseconds of performance might be harder to squeeze out of Rust making this effort futile.
In which case I would rather brush up my C++ and get with him on it.

https://redd.it/1h1b918
@r_cpp

Читать полностью…

C++ - Reddit

I'm New to C++

I wanna start learning C++ and I don't know where to learn from, I don't have prior knowledge to any programming languages. I don't know if i should refer books or videos or something it else.
If anyone can help me with this or share your materials that helped you to learn C++ from scratch.

https://redd.it/1h14mal
@r_cpp

Читать полностью…

C++ - Reddit

Join TYNET 2.0: Empowering Women in Tech through a 24-Hour International Hackathon!

RAIT ACM W Student Chapter presents...

⚜️ TYNET 2.0: International Women Hackathon ⚜️

"Code is the language of the future; every line you write builds the world of tomorrow."

🔸 Eligibility Criteria: For Women Only

🔰 Round 1

Mode: Online

Registration Start Date: 21st November 2024

FREE OF COST

Last Date of Round 1: 10th December 2024

15 teams progress to Round 2 🎉

📍 Round 2 Venue: Ramrao Adik Institute of Technology, Nerul

🌐 TYNET Official Site: rait-w.acm.org/tynet

💸 Cash Prize of 30,000 INR

🎁 Prize Pool and Goodies to be revealed soon! 🌟

✅ Certificates for All Participants

🚀 Register Now on Unstop

https://unstop.com/o/NyFcYPl?lb=9JFiN2QW&amp;utm\_medium=Share&utm\_source=shortUrl

📄 View the Brochure:

https://drive.google.com/file/d/1pYgRS38yGjJSgHN6C8dj2DJuxO1qU8-l/view?usp=sharing

For any queries, please contact:

📧 tynet.raitacmw@gmail.com

📧 reachraitacmw@gmail.com

See you at TYNET 2.0! 🚀

https://redd.it/1h11d90
@r_cpp

Читать полностью…

C++ - Reddit

So you want to write a KMail plugin?
https://datagirl.xyz/posts/kontact_plugin_writing.html

https://redd.it/1h0ytng
@r_cpp

Читать полностью…

C++ - Reddit

Best way to setup IDE assuming no build/compiler setup is possible?

I'm just looking for IDE quality of life basics, like Ctrl+click navigation from a function call to its definition/declaration, symbol recognition and highlighting, auto completion of symbols in scope, auto completion of an object's available functions, etc.

I'm working in a very old C++ codebase with a custom, distributed build system. Builds take a while, 5 mins at least. I use VSCode and CLion. But neither handles it very well. VSCode behaves inconsistently, and might be getting confused because of the size of the project (pretty large). For example it won't even give me the red squiggle when I reference a variable that is out of scope (or maybe hasn't been declared). Sometimes Ctrl+click navigation works, sometimes it just does nothing. CLion seems to base everything on the build/compiler config and that is not really possible here. Global search is ok for navigation, but some other basics don't work.

Is there any tool that can index my code using a generic interpretation of the language to provide these IDE functions, without actually building it or being set up to build?

https://redd.it/1h0rk24
@r_cpp

Читать полностью…
Subscribe to a channel