Rappel: Compose Algorithms, not Iterators - Google's Alternative to Ranges - C++Now 2024
https://www.youtube.com/watch?v=itnyR9j8y6E
https://redd.it/1et4cpp
@r_cpp
A first look at the voting results for Meeting C++ 2024
https://meetingcpp.com/meetingcpp/news/items/A-first-look-at-the-voting-results-for-Meeting-Cpp-2024.html
https://redd.it/1esqvlb
@r_cpp
Access a function's return value in C++ scope guard
https://blog.the-pans.com/return-value-scope-guard/
https://redd.it/1esnlm4
@r_cpp
Temporarily dropping a lock: The anti-lock pattern - The Old New Thing
https://devblogs.microsoft.com/oldnewthing/20240814-00/?p=110129
https://redd.it/1esnilw
@r_cpp
just one.
Does anyone know why this is happening or what's the best way to avoid it?
https://redd.it/1esl5s6
@r_cpp
Microsoft engineer: Library dependencies were why UWP and Windows Phone failed
https://www.youtube.com/live/hQJSr2m8qSY?t=3719s
https://redd.it/1esdd6j
@r_cpp
Exploring Rust-C++ Interoperability
Hi everyone,
I’m excited to share a new project I’ve been working on that focuses on Rust-C++ interoperability. The goal is to provide a resource that makes it easier for developers to experiment with integrating Rust into existing C++ codebases.
The repository is containerized for easy setup and includes several practical examples that demonstrate how Rust and C++ can work together. I’ve recently made significant updates, and I’m eager to hear your thoughts.
If you’re interested in this area, I’d love for you to check out the repo, share your feedback, or contribute if you have ideas or examples to add.
Here’s the link: https://github.com/omeryusufyagci/rust-cpp-integration/tree/main
Thanks in advance for your support and interest!
https://redd.it/1esb5gp
@r_cpp
Embedded GUI other than Qt ?
What other frameworks do you recommend other than Qt to develop gui apps that will work on embedded ?
https://redd.it/1es69nz
@r_cpp
wrap std::future in boost::unique_future
Hello,
Since we are using vcpkg (and don't want to change that), we only have access to boost-Thread version 2, unfortunately. So `boost::async` calls `std::terminate` when the policy `boost::launch::deferred` is used, probably because in Thread version 2 that is not supported.
I also can't switch to `std::future` because I need `boost::wait_for_any`.
Is there a way to use `std::async` and wrap the returned `std::future` in a `boost::future`?
Or does anyone see another way to use mixed deferred and async futures with `boost::wait_for_any` when only Thread version 2 is available for boost?
https://redd.it/1es49s0
@r_cpp
Can some explain this to me like I'm a dummy
What is the difference between
Int x = 5
Int x {5}
Int x (5)
Onyx - a High-level Rendering Library in C++!
I have created library called Onyx, a high-level, cross-platform rendering engine in C++ that provides several abstraction layers on top of OpenGL and GLFW.
If you have ever wanted to code games or apps yourself without using a game engine in a language as complex as C++, Onyx is exactly what you need. Here are just some of Onyx's many features:
- Creating & Customizing Windows
- Input Handling (keyboard, mouse, controllers/gamepads)
- Rendering:
- Hardcoded meshes
- Loaded models (OBJ format)
- GUI and Text
- Lighting (Ambient & Directional), Fog
- Colors and/or Textures
- Camera (movement in 2D or 3D world)
- Transforms (position, rotation, scale) for Renderables and the Camera
- Presets for Meshes, Shaders, and Renderables
- Monitor info
- Extensive Matrix & Vector Math
- Thread-safety (except functions that use OpenGL)
- Various system functions (clipboard access, modifier key states, and more)
There are build instructions and several tutorials on the GitHub Wiki. Stop sleeping and USE ONYX!!!
Email jopo86dev@gmail.com with any questions!
https://redd.it/1ej5h81
@r_cpp
The difference between undefined behavior and ill-formed C++ programs - The Old New Thing
https://devblogs.microsoft.com/oldnewthing/20240802-00/?p=110091
https://redd.it/1eisu15
@r_cpp
C++ Show and Tell - August 2024
Use this thread to share anything you've written in C++. This includes:
* a tool you've written
* a game you've been working on
* your first non-trivial C++ program
The rules of this thread are very straight forward:
* The project must involve C++ in some way.
* It must be something you (alone or with others) have done.
* Please share a link, if applicable.
* Please post images, if applicable.
If you're working on a C++ library, you can also share new releases or major updates in a dedicated post as before. The line we're drawing is between "written in C++" and "useful for C++ programmers specifically". If you're writing a C++ library or tool for C++ developers, that's something C++ programmers can use and is on-topic for a main submission. It's different if you're just using C++ to implement a generic program that isn't specifically about C++: you're free to share it here, but it wouldn't quite fit as a standalone post.
Last month's thread: https://www.reddit.com/r/cpp/comments/1dy404d/c_show_and_tell_july_2024/
https://redd.it/1eiclin
@r_cpp
Using Clang with CLion in Windows
Hello everyone, I've been trying to use the the Clang compiler (the one that comes with the Visual Studio installation), in CLion in windows, but I keep getting the following error:
-- The C compiler identification is Clang 17.0.3 with GNU-like command-line
-- The CXX compiler identification is Clang 17.0.3 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: D:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/bin/clang.exe
-- Check for working C compiler: D:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/bin/clang.exe - broken
CMake Error at D:/Program Files/JetBrains/CLion 2024.1.4/bin/cmake/win/x64/share/cmake-3.28/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler
"D:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/bin/clang.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: 'D:/Ingenieria/LINKER/QuarkPhysics/cmake-build-debug-clang/CMakeFiles/CMakeScratch/TryCompile-nl99wd'
Run Build Command(s): "D:/Program Files/JetBrains/CLion 2024.1.4/bin/ninja/win/x64/ninja.exe" -v cmTC_c20fc
[1/2] D:\PROGRA~4\MICROS~1\2022\COMMUN~1\VC\Tools\Llvm\bin\clang.exe -O0 -g -Xclang -gcodeview -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -MD -MT CMakeFiles/cmTC_c20fc.dir/testCCompiler.c.obj -MF CMakeFiles\cmTC_c20fc.dir\testCCompiler.c.obj.d -o CMakeFiles/cmTC_c20fc.dir/testCCompiler.c.obj -c D:/Ingenieria/LINKER/QuarkPhysics/cmake-build-debug-clang/CMakeFiles/CMakeScratch/TryCompile-nl99wd/testCCompiler.c
[2/2] C:\Windows\system32\cmd.exe /C "cd . && D:\PROGRA~4\MICROS~1\2022\COMMUN~1\VC\Tools\Llvm\bin\clang.exe -fuse-ld=lld-link -nostartfiles -nostdlib -O0 -g -Xclang -gcodeview -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -Xlinker /subsystem:console CMakeFiles/cmTC_c20fc.dir/testCCompiler.c.obj -o cmTC_c20fc.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:cmTC_c20fc.lib -Xlinker /pdb:cmTC_c20fc.pdb -Xlinker /version:0.0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
FAILED: cmTC_c20fc.exe
C:\Windows\system32\cmd.exe /C "cd . && D:\PROGRA~4\MICROS~1\2022\COMMUN~1\VC\Tools\Llvm\bin\clang.exe -fuse-ld=lld-link -nostartfiles -nostdlib -O0 -g -Xclang -gcodeview -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -Xlinker /subsystem:console CMakeFiles/cmTC_c20fc.dir/testCCompiler.c.obj -o cmTC_c20fc.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:cmTC_c20fc.lib -Xlinker /pdb:cmTC_c20fc.pdb -Xlinker /version:0.0 -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames && cd ."
lld-link: error: <root>: undefined symbol: _mainCRTStartup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Does anyone know a workaround that does not involve installing MSYS2 or Cygwing?
Here is a pic of my toolchain setup: [https://imgur.com/M1Tc8GZ](https://imgur.com/M1Tc8GZ)
https://redd.it/1ei1257
@r_cpp
WG21, aka C++ Standard Committee, August 2024 Mailing
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/#mailing2024-08
https://redd.it/1et4bfn
@r_cpp
Starting a GUI academic project: Where to Begin?
Greetings.
I'm looking to turn a command line c++ program made for academic purposes with Visual Studio 2022 into a GUI application, and I don't really have an idea on where to start. I've been looking at libraries to use, and ImGUI looks ok (I can't use Qt due to the prohibitively expensive license), but I don't really know which one to go with, or how to add them to a project. Are there any good beginner-friendly libraries (that are preferably free and open-source)?
For context, the latest c++ class I've taken is Object-Oriented Programming, so I feel as though I'm a bit in over my head.
Any help/advice would be appreciated.
https://redd.it/1et0q3u
@r_cpp
Project idea recommendations in c++?
Hi im looking to build my c++ knowledge more and im looking for project ideas. im not really a beginner in c++ i would say im an intermediate to advanced a little and im into projects that are related to cryptography and networking.
Feel free to recommend any intermediate to advanced projects tho
https://redd.it/1esqmht
@r_cpp
A better way to to handle ranges of value (?)
For Context: I am tutoring my nephew on how to handle if else statement when it suddenly hit me. How could i make the small activity (this code) more efficient?
string convertGrade(int grd)
{
if( grd >= 90)
{
return "Excellent";
}
else if( grd<=89 && grd >= 75 )
{
return "Good";
}
else if( grd<=74 && grd >= 60 )
{
return "Passing"
}
else
{
return "Better Study for Next Time"
}
}
I'm not really that good at programming as my work is more hardware focus so I am not well verse in it.
https://redd.it/1esmkcz
@r_cpp
Implementing Rectangular Collision Detection
https://gist.github.com/sortira/b658d0982695ec6ebe347c52d167a47c
This gist is my first attempt at writing proper C++ code to solve a problem (rectangle collision/overlap detection).
I've been reading the 4th edition of The C++ Programming Language by Bjarne Stroustroup and this is my first code. Coming from a Java background it is a little difficult to C++-ify things.
All and any suggestions are welcome!
https://redd.it/1esmr1w
@r_cpp
Class constructor being called multiple times
Hi community, I'm having some issues with my game engine and the physics engine, it seems like the constructor of the following class is being called multiple times:
class
PhysicsComponent
{
public
:
PhysicsBody body;
Vector2 size;
int
type;
PhysicsComponent(
const
PhysicsComponent&) =
default
;
PhysicsComponent(Vector2 position = Vector2(0,0),
Vector2 size = Vector2(0,0),
bool
mode =
true
,
bool
fixedRot =
true
,
int
type = 0,
float
friction = 0
) : size(size), type(type)
{
switch
(type)
{
case
0:
{
body = CreatePhysicsBodyRectangle(position, size.x, size.y, 10);
}
break
;
case
1:
{
body = CreatePhysicsBodyCircle(position, size.x, 10);
}
break
;
case
2:
{
body = CreatePhysicsBodyPolygon(position, size.x, size.y, 10);
}
break
;
}
body->enabled = mode;
body->freezeOrient = fixedRot;
body->staticFriction = friction;
body->dynamicFriction = friction;
body->mass = 10;
std::cout << "PhysicsComponent created for position: " << position.x << ", " << position.y << std::endl;
}
};
How do I know? because the functions CreatePhysicsBodyRectangle are being called multiple times from the same method.
My engine is ECS so I have a method to add components to an Entity, here is the method:
template<class AlphaComponent, class ...AlphaArgs>
void Registry::addComponent(Entity entity, AlphaArgs && ... args)
{
ComponentId componentId(0);
if (componentIds->find(std::typeindex(typeid (AlphaComponent))) == componentIds->end())
{
componentId = Component<AlphaComponent>::getId();
componentIds->insert(std::makepair(std::typeindex(typeid (AlphaComponent)), componentId));
}
componentId = (*componentIds)[std::typeindex(typeid (AlphaComponent))];
EntityId entityId = entity.getId();
if (componentId >= componentPools->size())
{
componentPools->resize(componentId + 1, nullptr);
}
if (!(componentPools)[componentId])
{
std::shared_ptr<Pool<AlphaComponent>> newComponentPool = std::make_shared<Pool<AlphaComponent>>();
(componentPools)componentId = newComponentPool;
}
std::sharedptr<Pool<AlphaComponent>> componentPool = std::staticpointercast<Pool<AlphaComponent>>((*componentPools)[componentId]);
if (componentPool == nullptr)
{
throw std::runtimeerror("Unable to create the memory");
}
if (entityId >= componentPool->getSize()) {
componentPool->resize(numEntities);
}
AlphaComponent newComponent(std::forward<AlphaArgs>(args)...);
componentPool->setItem(entityId, newComponent);
if (componentsPerEntity->find(entityId) != componentsPerEntity->end())
{
componentsPerEntity->insert(std::makepair(entityId, std::unorderedset<ComponentId>()));
}
(componentsPerEntity)[entityId].insert(componentId);
(entityCmpSignatures)entityId.set(componentId);
Logger::Log("Component id = " + std::tostring(componentId) + " was added to entity id " + std::tostring(entityId));
}
//Call to the adding method:
mario.addComponent<PhysicsComponent>(Vector2(100,100),Vector2(70,88), true, true, 0, 2);
So the problem is that I end up having a lot of bodies being added to the Physics Engine when there should be
Temporarily dropping a lock: The anti-lock pattern - The Old New Thing
https://devblogs.microsoft.com/oldnewthing/20240814-00/?p=110129
https://redd.it/1esb95h
@r_cpp
Feeling Stuck as a C++ Team Leader – Seeking Advice and Opportunities
Hello, Reddit community,
I’m currently in a tough spot with my job and could use some advice or leads. I’m working as a C++ Team Leader for a company that manufactures variable message signs, but lately, I’ve been feeling really stuck. The work environment has become increasingly toxic, there’s little to no room for growth, and the management style here isn’t something I can thrive under.
# About Me:
I’m an experienced software engineer with a strong focus on C++ and Qt development. Over the years, I’ve worked with a variety of programming languages including C#, Java, Swift, and Objective-C. I have solid experience in database management (SQL, MySQL), and I’m comfortable across multiple operating systems like Windows, Linux, macOS, and Android.
My work also includes network technologies such as UDP, TCP, HTTP, SNMP, and NTCIP, and I’m well-versed in version control systems like SVN and Git. I have a background in embedded systems using Raspberry Pi and BeagleBoneBlack, and I’ve built user interfaces with QWidgets, QML, and WinForms.
Beyond development, I’m skilled in deployment, testing, and service management with tools like Jenkins. I’ve been recognized as the best software engineer for three consecutive years, and though I’m currently based in Serbia, I’m open to relocation or remote work.
# What I’m looking for:
I’m seeking a role where I can continue working with C++ and Qt, ideally in a healthier work environment with opportunities for growth. However, I’ve noticed a lack of open roles or any suitable opportunities in the market right now, which has been pretty discouraging.
# How you can help:
* Advice: If anyone has been in a similar situation, how did you navigate it?
* Job Leads: If you know of any openings or companies that might align with my skills, I’d love to hear about them.
* Networking Opportunities: I’m open to connecting with anyone who might have insights or connections in the industry.
Any support or guidance would be greatly appreciated. I’m really eager to make a change and get back to doing work that I’m passionate about.
Thanks for reading, and I’m looking forward to any advice or leads you might have.
https://redd.it/1es74t0
@r_cpp
Boost v1.86.0 released
https://www.boost.org/users/history/version_1_86_0.html
https://redd.it/1es5syd
@r_cpp
Why do people use neovim over vscode or a modern ide?
what makes neovim more appealing than simply using the neovim plugin in vscode or clion? I feel like nvim takes a lot of config to make it good just so it can behave like vscode
https://redd.it/1ejduqc
@r_cpp
Can some explain this to me like I'm a dummy
What is the difference between
Int x = 5
Int x {5}
Int x (5)
ICPP-VSCode extension is released
Within an IDE frontend should be easier and more convenient to use the icpp package, you can download it at the icpp-vscode release page or search "icpp" in vscode extension market.
Interpreting C++ in vscode with the icpp backend, and writes the execution result into the Output/ICPP channel.
https://redd.it/1eixj0d
@r_cpp
C++ and Excell
I'm wanting to start making a desktop app to handle some data simulation. At the moment, this is all handled via Excell and a lot of VBA. I'm wanting to start moving away from this, however, I need to move slowly due to time constraints. I'd like my current Excell sheet to continue working but slowly start offloading a lot of features off of it. The end goal would be for excel to entirely stop being involved in this simulation or at least minimally involved. I may choose to at some point allow a user to do data entry in Excell and import/export it to this app, but that's a down the road problem. For now, though, my challenge is going to be creating a GUI that contains a number of buttons that can turn on and off items on the Excell sheet. Yes, I know there are ways to do this natively in Excell but, again, this is just a temporary step while we slowly convert over. Is there a good way to do this? I have done some structured text programming but I haven't used a lot of C++ and when I have it's been for a class or personal use, not intended for non-programmer user interaction.
https://redd.it/1eiraiw
@r_cpp
Problen with CLion
Forst off all I want to apologise for my bad englisch. It really is hard for me to explain something like this.
I have a problem where when I write something in a switch statement. After I write case ...: and then press enter it wants me to continue to write more to the right. That is exactly what I want, but after that line it goes back to the row where I wrote case . It's infuriating and I am new with CLion so I would appreciate some help.
https://redd.it/1ei8rk7
@r_cpp
How to do real things
Hello im a beginner in cpp and i have alredy made some projects, but i feel that projects are not useful in te real world or they are much simple for the real world. My question is how i get the next level? Like, what i need to study to be capable to make a useful app, I dont mean inovative, just useful, thats interact with real things. How you guys get this next level, pls tell your experience.
https://redd.it/1ehw8ku
@r_cpp