Any advice for learning C++ (I might do Cherno tutorials)
Ok so I already know Html , CSS and just got my Udemy Python certificate and while I practice Python I tried making Games but realised that man Python games is hard.
So ill be doing other projects with Python but in my free time I want to start learning C++.
As my other friends that do know both python and C++ say its much easier to create games in I'm looking to make something simple 2D and later on when I'm more experienced 3D games. so any recommendations? and tips.
https://redd.it/1byrh13
@r_cpp
How not to check array size in C++
https://pvs-studio.com/en/blog/posts/cpp/1112/
https://redd.it/1byrf06
@r_cpp
New to C++, any recommendation on how to start practicing?
I've just started learning C++ online through a community college and I'm taking a data structures, but the assignments they give me are lacking in coding, mostly they are just pseudo code. Where or how can I start practicing for c++ and to begin learning and improving?
https://redd.it/1byg0hv
@r_cpp
Intel ICPX OpenMP offload to NVidia
Has anyone had any luck configuring the compiler? Can you point me to an article describing the process? I have a pretty good idea of how to do it on GCC but I'm having an error such as "unable to find NVPTX binary" when the offload target is set to nptx.
https://redd.it/1by8fym
@r_cpp
Online Compiler for OpenCV
Can you suggest me some good online Compilers(if any) having builtin OpenCV library.
(Something where you don't have to do anything before compiling the code)
https://redd.it/1by942h
@r_cpp
How do you test your application bundle/installer on a fresh install?
On Linux, it's easy to check you've packaged your app properly with all its dependencies. You just set up a VM with a fresh Linux installation, and install your app into it and verify that it works.
But what about on Mac? My app bundle works fine on my dev machine, but as a sanity check I'd really like to try it on a fresh install. In the past I've set up a VM, but I remember it being a massive pain. What do most developers do?
https://redd.it/1by6aih
@r_cpp
Reactive Programming for C++
I've used reactive programming extensively in other languages and I've developed a few of my own libraries. Now I'm partway through porting my efforts to C++, since I believe reactive programming can also be of use in systems software and desktop applications where C++ is still my go to language.
If you're interested in using reactive programming in C++, check out the Live Cells C++ library.
Anyway to summarize what it can do:
You can declare cells which hold a pieces of data:
auto count = livecells::variable(0);
You can observe cells in other cells, thus creating a cell which is a function of other cells:
auto a = livecells::variable(1);
auto b = livecells::variable(2);
auto sum = livecells::computed(= {
return a() + b();
});sum
is recomputed automatically whenever the value of a
or b
changes.
Actually sum in this example can be simplified to the following:
auto sum = a + b;
You can run a function whenever the values of one or more cells change:
auto watcher = livecells::watch([=] {
std::cout << "The sum is " << sum() << "\n";
});
The *watch* function defined above is run automatically whenever the value of `sum` changes.
I've found this paradigm to be very useful for handling events and keeping the state of an application, be it a GUI desktop application, systems software or a server, in sync between its various components.
NOTE: The library is still in early stages, with the documentation being rough in some places and there is still some opportunity for optimization. What do you think?
[https://alex-gutev.github.io/live\cells_cpp](https://alex-gutev.github.io/livecellscpp)
https://redd.it/1by33bf
@r_cpp
"CMake Options Visibility Configuration" What should i do ?
https://redd.it/1by0016
@r_cpp
Global arrays vs passing arrays into functions
When to have globally accessible arrays accessible across cpp files vs passing them as parameters?
One benefit I can think of is that you can pass with const
which adds a layer of safety.
Besides that, best practices? Other notable benefits?
https://redd.it/1bxv7h9
@r_cpp
GUI applications
I am developing a photo editing tool in C++. Upon research, I found a ton which includes Qt, ImGUI, OpenGL etc. I'm quite new to such frameworks. I'd like to get some opinion on which one would be the best. (maybe the most used/opensource)
https://redd.it/1bxoslv
@r_cpp
C++20 modules and Boost: an analysis
https://anarthal.github.io/cppblog/modules
https://redd.it/1bxggim
@r_cpp
Learning cpp for fullstack web dev
Now before you call me crazy I want to give you some background
I come from a cs background and it’s been years I’ve not touched to a low level language and I feel like it’s time for me to get back to it. Either rust/cpp/go(idk if it should be called a low lvl language)
I’m a typical “full stack js” dev with good experience in front end (react/react native mainly).
For fun, I recently tried to make a node addon in cpp that I’d call from a ts file and it’s like it opened a new world to me, the ability to have some part of my backend or front end optimised in a lower level language.
Now idk if it is something I’ll ever do at work but for any of my personal project it it something I’d like to explore.
But I don’t know where to start or if any of you guys had experience with this. It seems that if i would need to do some cpp it would be for a very precise problem, for example doing some video treatment when a user upload a video. And it seems to me that it would require good cpp skills and also good skills in the field of what I’m going to use cpp for, so I don’t really know where to start.
If there is any web dev here that used to build addons or even micro services in cpp (it could be use also on the mobile, some react native bridges in cpp) I’d be glad to hear about your background and how did you learn doing this.
Maybe I’m also overthinking everything aha
https://redd.it/1bxfhvw
@r_cpp
Applying concepts from Rust in C++
Hey, I'm not a Rust expert (never wrote any serious code) but I really like a lot of concepts of the language. In my daily life I write C++ and there are a few concepts from Rust that I now frequently apply to how I write C++.
Enums with values
I like Rust enums since you can add values to the enums constant (e.g. Option enum has None without a value and Some with a value). In type theory it's called algebraic datatype. In C++ we have variants and can define helper structs to achieve something similar:
struct Some { T value; };
struct None { };
using Optional = std::variant<Some, None>;
auto value = [] {
// Complex initializer
return result;
}(); // notice the invocation
Lazy evaluation in C++ is trivial !
Lazy evaluation is a thing I've always dreamed of implementing, however my skills were lacking to say at least. After half of semester of forced functional programming in Haskell and one long evening searching around the internet, I've finally managed to understand how trivial implementing lazy evaluation in C++ really is...
If you ever need basic lazy evaluated math interface to jumpstart your math library, here it is:
https://github.com/Panjaksli/LazyVal/tree/main
It works with std::vector perfectly out of the box, or any dynamic vector class that has method size(), constructor for a given size, and operator[\] overload.
Can easily be extended to support more unary expressions (sqrt, log, pow ... you name it)
God, I love C++ <3
https://redd.it/1bx6ci7
@r_cpp
What Graphics Lib for Crispy Fonts?
I've been trying to make a little pet project Terminal emulator in C++ and I can't stand how the text looks in SDL2. I've tried some different methods in SDL2 but I'm about done trying there. I hate how they implemented graphics programming anyway.
I've seen that SFML is a good option as well, but I was curious to know if there are any libraries or neat shader tricks that you guys are aware of that could land some very crispy, proper vector based text!
https://redd.it/1bwron6
@r_cpp
cmake not able to compile a cppcheck program
I am not a c++ dev but I would like to build and compile a cppcheck program in my dockerfile.
I installed cppcheck and clang compiler in my docker but I am getting a error like this:
git clone --branch main --single-branch https://github.com/danmar/cppcheck.git && cd cppcheck && mkdir build && OMPILER ON.. && make - 2 && make install && cd ../.. && rm -rf cppcheck:
Cloning into 'cppcheck'
The CXX compiler identification is Clang 16.0.6
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: /usr/bin/clang++ - skipped
Detecting CXX compile features
Detecting CXX compile features done
CMake Error at cmake/options.cmake:28 (message):
Invalid USE_MATCHCOMPILER value 'ON'
Call Stack (most recent call first):
CMakeLists.txt:18 (include)
Configuring incomplete, errors occurred!
Dockerfile:32
Why am I getting this and how to fix this ?
https://redd.it/1byrj1o
@r_cpp
OOP project
So I am doing Bachelors in Mechanical engineering and I have a c++ oop course in 2nd semester .
I have to make a semester end project in which the concepts of oop can be used.
Please suggest me some projects where the basic concepts of OOP can be used while it can be relatable to mechanical engineering as well.
Thank you
https://redd.it/1byfui2
@r_cpp
Biggest mistake in development of C++
Early on in c++ they could have done one thing that would have made life far simpler for every C++ developer.
I've been programming for 35 years. I'm lazy. If I can find a way to not do work I will. I hate creating make, batch and even more so cmake files. There is no good reason for any of that.
The reason we have to comes down to the fact they never tied the header and libraries together.
Take SDL_image as an example. The header is SDL_image the .lib .a and .dll are SDL2_image which is what the linker option is -lSDL2_image
There is no easy or guaranteed way currently to identify which libraries or headers belong together or tell from the header what linker option is needed to include the current library.
If they had you wouldn't need to write make files. You could simply have a program run everything without user input.
It wouldn't take much either. Something as simple as#define libraryname "SDL2_image"
would go a long way. If it was included in the header files that needed a library.
You would still need to know where the libraries are located but the program could run a search on install or the first time it does a compile and if it doesn't find them ask for user input and then store it.
But for the most part this would allow making something more automated than what I currently can.
Currently I can automate up to the point were I need to enter the linker information in at least once per project if my system hasn't seen the library before or I haven't added it to a list of associated headers and libraries.
A lot of this is what some current IDEs do. Codeblocks for example you provided it search directories for the linker and header files, you provide it the libraries. You don't have to create a make file. It works that out and builds the project.
So auto building is entirely possible. But what we have an issue with is automatically typing the libraries and headers together. Currently the only way to tie them together is a list of headers to libraries or manual input at some point. That single line above would be an easier solution than trying to get changes made to the library files and DLLs.
It would mean not having to modify a make file each time you add to a project. Not having to create one every time you create a new project. Like I said I'm lazy.
I rather spend my effort on the code not doing something that shouldn't need doing.
https://redd.it/1bydjxm
@r_cpp
Modern C++ Asynchronous Learning
As in the title, I am looking for resources to learn asynchronous programming in C++, ideally with object oriented design and covering most of the modern (C++20 and later) techniques. Also with coroutines which I reckon are related. Any help would be appreciated.
https://redd.it/1by8xq5
@r_cpp
Desugarize C++ using NSA Ghidra decompiler
https://www.youtube.com/watch?v=To2iEh0icMY
https://redd.it/1by71e2
@r_cpp
ClangQL: A tool to run SQL-like query on C/C++ Code
https://github.com/amrdeveloper/clangql
https://redd.it/1by58c9
@r_cpp
vector_view library: a slice of a vector with support for emplace and erase
[https://github.com/Beosar/vector-view](https://github.com/Beosar/vector-view)
This library allows you to use a slice of a `std::vector` like a regular `std::vector` and even add/remove elements.
This is the first library that I've shared publicly. It's just a couple lines of code but I hope it is useful nonetheless.
https://redd.it/1by37mt
@r_cpp
Abstract class in C++ and DI
Hi, I come from a C# background, and now I need to implement my new project in C++. However, I'm struggling to understand the usage of abstract classes in C++. In C#, we have interfaces, which I believe are equivalent to abstract classes in C++.
I mainly used interfaces for Dependency Injection (DI), but it seems that DI isn't widely used in C++ (I can't find any active DI framework/library for C++). Why is that?
What if I want to start with one implementation of an abstract class and switch to a new one throughout my entire source code in the future? What is the best strategy other than DI?
https://redd.it/1bxwowy
@r_cpp
Curl impersonate include
Hi Folks,
​
I'm building my first cpp program. I've stumbled into an issue whereby I'd hoped to include essentially two versions of the same library. At first i thought that'll be fine, just wrap a class around it. Then i ran headfirst into a pile of linker errors.
I've read namespace wrapping is maybe an option. However as i understand it that would require me to go through library source code and wrap every function in a namespace? Is that correct?
Is there anyway around this. The library I want to include is curl impersonate which is just curl edited to make requests behave more like chrome (one library) or firefox (another library).
​
Any suggestions or is it a no go?
​
https://redd.it/1bxrngj
@r_cpp
Hardware API
I want to create a project to create APIs (in C++) responsible to communicate with hardware(sensor), to retrieve the data from sensor. It will be a big and complex project and to make it robust thought to use some frameworks and suggestions on that. Or if anyone know some good and simplified work/course from where i can take reference will be nice.
https://redd.it/1bxmnjj
@r_cpp
A case in API ergonomics for ordered containers
https://bannalia.blogspot.com/2024/04/a-case-in-api-ergonomics-for-ordered.html
https://redd.it/1bxflyz
@r_cpp
Please never assume.
It turns out that with the new standard, the best programming language will become even better. Now C++ has a "pinky promise", the violation of which leads to undefined behavior (UB). Let me jump straight to an example:
int f(int x, int y) {
[[assume(x == 27)]];
[[assume(x == y)]];
return y + 1;
}
__builtin_assume(...)
) or GCC (__attribute__((assume(...)))
), it's just that previously this was wrapped in some macro inside the project, which could also slip in an assert for debug builds, for example.When to use/avoid using std::ranges, views?
I saw this video some time ago where Nicolai Josuttis mentioned many problems in C++ 20 ranges, views. So now I have doubts whether to use ranges at all? If yes, what are the scenarios when they should be used and what are the scenarios when they should be avoided?
https://redd.it/1bx6ube
@r_cpp
Can’t find eigen documentation .
Does any one know why https://eigen.tuxfamily.org/dox/classEigen11Matrix.html servers down ? Or any other place to access its documentation ?
https://redd.it/1bx1gl7
@r_cpp
How to create an Asynchronous Web Server in C++ Under 40 Lines Of Code | Nodepp
EDBCBlog/how-to-create-an-asynchronous-web-server-in-c-node-0e167334c1c1" rel="nofollow">https://medium.com/@EDBCBlog/how-to-create-an-asynchronous-web-server-in-c-node-0e167334c1c1
https://redd.it/1bws1kp
@r_cpp