812,594 questions
0
votes
0
answers
4
views
Manipulate struct data vertically
I have a function that takes three structs and list of widgets. I want to link all of these widgets with particular field in struct and then process accordingly.
struct SomeStruct { QString first; ...
-1
votes
0
answers
10
views
A reasonable conversion in the member function pointer but an error occurred?
I always thought that when I converted a member function ptr in C to a member function ptr in A, I just had to make sure that the call was pointing to an C entity , but that was a mistake. Does the ...
-4
votes
4
answers
76
views
To find union of two sorted arrays
In the problem, we have to find union of two arrays sorted in non-decreasing order.
#include<bits/stdc++.h>
using namespace std;
vector<int> findUnion(vector<int>&a,vector<int&...
1
vote
1
answer
44
views
Xorg: hardware-independant way to find if physical keyboard is present
It's needed to alter GUI in order to help with input using touch screen.
Pretty sure it's possible because various high-level software suites or programming environment (java, javascripts, desktop ...
-3
votes
1
answer
56
views
C++ Injection dll export function
I am trying to inject a dll in a windows .exe process for example notepad.exe, the injection works fine but when the dll is already injected in the process and I try to call the exported function it ...
0
votes
0
answers
65
views
Compile Time unique hash for variables
is there any ways of making unique hashes for each variable in compile time.
C++ allows block scopes which can result in same named variables inside one function so i cannot just do:
#define MACRO(...)...
0
votes
0
answers
43
views
How do I pass the same array between two different modules?
I am trying to utilize modules with arrays.
I am trying to make a module that gets data input from a user's keyboard, and a different module that prints the array the user inputs (the modules are for ...
0
votes
1
answer
38
views
Creating a console window from a DLL for debugging aims
I have implemented a DLL (C++, VisualStudio, Windows), which extends function of an another program (further - main program).
I don’t know internal architecture of the main program, except it is GUI-...
-2
votes
1
answer
101
views
Operators "new" and "delete" in C++
I ran into a problem, from an exercise in Bjarne Stroustrup's book Programming: Principles and Practice Using C++ (2nd edition), at the very end of chapter 17 for the Exercises section, exercise 7:
...
0
votes
0
answers
22
views
Doxygen ignores NO_DIAGRAM
I'm documenting a C++ project with Doxygen and I want the dependency graph to only include my header file, not other libraries. I have it like this:
#ifndef CJT_ROBOT_HH
#define CJT_ROBOT_HH
#include &...
0
votes
0
answers
90
views
Is there a default build-in function or template which returns zero?
Sometimes I need a function or template which returns zero like in the example below (artificial, of course, for sake of simplicity).
I am fine to write everywhere []() { return 0.0f; }, but taking ...
2
votes
1
answer
60
views
How to call in template a function with different amount of arguments?
I want my template to take lambdas with different number of parameters and be able to handle them.
In the code below template process takes callable object (function) but doesn’t know whether passed ...
-3
votes
0
answers
40
views
undefined reference to "WinMain" [duplicate]
I am new to c++ and trying to use SDL2 on my Mingw Compiler(Msys2)
After I compiled with #include "SDl2\SDL2.h" my compiler kept giving me this message:
C:/M/B/src/mingw-w64/mingw-w64-crt/...
0
votes
0
answers
28
views
Setting up a ST7789 TFT display in C++ for Raspberry Pi Pico W
I loaded the pio_st7789_lcd example from pico-examples (https://github.com/raspberrypi/pico-examples) into VSC and it works fine on my Pico W with an attached ST7789 128x160 module. But I only worked ...
-3
votes
1
answer
68
views
Visual Studio Debugger useful for debugging my OpenGL code?
Is it possible to use the Visual Studio debugger to debug my GLFW/OpenGL code? I get an exception on a glDrawElements() call which provides useless info. Obviously I have not set things up correctly, ...
0
votes
1
answer
59
views
Understanding why certain preprocessor macro overloads don't work
I'm currently working in VS2022 writing a set of macros using the variadic macro tricks described in Overloading Macro on Number of Arguments. Specifically, I'm trying to do 3 things with scoped types:...
0
votes
0
answers
58
views
windows application message queues similar to VxWorks? [closed]
I'm porting some software to Windows and looking for a simple implementation of message queues, similar to VxWorks. I've found MSMQ (Microsoft Message Queue) but that seems to be very dated, requires ...
0
votes
0
answers
29
views
How to access and interact with elements from a .ui.qml file in a parent .qml file? QT-QML
I’ve been working with Qt and C++ to create desktop applications based on QtWidgets, but now I want to transition to using QML.
I created a new project in Design Studio, and from File > Export ...
5
votes
1
answer
110
views
Why does one call of this function use NRVO while another call of the same function does not?
vector is a struct with two public members X and Y; a parameterized constructor that prints integer constructor called; a copy constructor that prints copy constructor called; and a move constructor ...
-2
votes
4
answers
122
views
Understanding Pointers to Arrays in C++ [duplicate]
In C++, there is a concept of a pointer to an array, where it is said to point to the "whole array" rather than just the first element. This idea confuses me. How can a pointer point to an ...
3
votes
1
answer
105
views
How can I get the memory distance in bytes between any two objects (if this measurement exists in a meaningful way)?
Pointer arithmetic is only defined behavior for pointers to elements of the same array (or one past the array).
Is there any defined behavior to get the distance in memory between two elements that ...
0
votes
0
answers
31
views
MPI program hanging because MPI_Isends not all being received
Motivation:
I am in the process of writing an MPI program for Kinetic Monte Carlo. Currently, I am writing a subroutine which communicates changes in halo sites (ghost sites), domain-crossing of ...
1
vote
1
answer
69
views
How can I extract data from a GeoTIFF at specific x, y co-ordinates in C++
I am an R user but a novice in C++. I need a C++ workflow that returns the value of a GeoTiff at a specific (x, y) coordinate. The GeoTiff contains 1 layer. The layer is a 2-dimensional array. Each ...
-1
votes
0
answers
73
views
Is it possible to call end() or rend() according an iterator type? [closed]
I am coding a function, which has three parameters:
a vector;
an iterator on this vector;
a distance (offset).
The vector's value type and type iterator's type are templatized: the iterator may be ...
0
votes
0
answers
59
views
Compiling GLAD with Clang and -pedantic flag on Windows
When compiling GLAD with Clang using these flags: -pedantic -Wall -Wextra I get these warnings:
C:/Dev/glad/include\KHR/khrplatform.h:189:9: warning: extension used [-Wlanguage-extension-token]
189 |...
0
votes
0
answers
18
views
linking std::filesystem on gcc 8.5 in EL8 container [duplicate]
I have an EL8 container on MacOS 14.5, running g++ 8.5
I have looked on here for similar issues and none seem to apply here or provide the solution I am looking for
The following code (test.cpp) gives ...
1
vote
1
answer
126
views
Need to call trivial destructor in standard compliant containers
I'm implementing my own version of standard-compliant containers. I read the following. It states that elements should be destroyed using the allocator destroy. Does it suggest a container must call ...
0
votes
1
answer
124
views
How to determine which is the primary drive in C++?
I want to find out on which hard drive my OS is installed (for now on Windows). I figured out how to match the physical drive to the model, but since "C:" is not always on drive 0, I would ...
0
votes
0
answers
105
views
lambda calls consume less memory than regular function calls? (stack overflow difference on lambda vs regular function)
with regular function:
#include <iostream>
#include <chrono>
using std::cout;
//timer
using A = std::chrono::steady_clock;
using B = std::chrono::duration<double,std::ratio<1>>...
0
votes
1
answer
80
views
Polymorphism alternatives when working with CUDA in C++
Edit: From the replies, I realized that what I really need is an alternative to virtual class methods in CUDA C++. I believe the solution proposed are better suited for my use case than the one ...
0
votes
0
answers
38
views
C++ with MicroPython [closed]
Is there any way to use a c++ script integrated with micropython. MicroPython will control my Pico W and its other components, while c++ can control my LCD screen.
I found this article (https://forums....
0
votes
0
answers
28
views
How to Use koffi with Struct Pointers
#pragma pack(1)
struct EnvInfo
{
DWORD dwSize;
WCHAR wszAppId[128];
ULONGLONG u64Qid;
};
extern "C" int __stdcall SDK360_Init(const EnvInfo* pEnvInfo);
this c++ code
const envInfo = ...
0
votes
0
answers
20
views
QWebEngineView giving strange errors when using TURN server for RTC communication
I am using QWebEngineView with QT with a web page that has an embedded Avatar that uses RTC to work.
On Chrome/Edge the page works fine but with QWebEngineView I get the following errors (some are ...
1
vote
2
answers
144
views
anonymous class in C++
In Java/Kotlin im used to do this:
interface MyInterface {
fun run();
}
And then creating anonymous instances like so:
val actions = arrayOf(
object: MyInterface {
fun run(){
//do ...
0
votes
1
answer
24
views
Duplicate Symbols while Linking CMake Project [duplicate]
I'm using CMake to build a project following this template.
The linking stage fails with duplicate symbols found my header files.
...
[100%] Linking CXX executable ../bin/user
duplicate symbol '...
-1
votes
0
answers
43
views
Print list given by user [closed]
How can we print the same list of the numbers in the output given by the user by using the loop before print the answer in c++?
Example:
Find the largest number in the list
We can get the list of the ...
-1
votes
1
answer
23
views
UE niagara Execute Behavior
I am learning Niagara, and I move some particles based on the RGB values in a texture. This is how I read the texture into a Grid 2D. When I reset the NS_Component in the blueprint, it does not ...
1
vote
1
answer
85
views
Passing temporary object for initializing reference member variable
Consider the below code snippet:
#include <iostream>
class B
{
public:
B()
{
x = 5;
std::cout << "B's default constructor called, creating object: " <&...
0
votes
0
answers
19
views
GRPC C++ Windows microservice Docker deployment
I have created simple GRPC C++ server which now has dependecy with GRPC dlls.
I am trying to learn how to containerize this GRPC server with Docker container.
Apart from base Windows docker image , ...
0
votes
0
answers
32
views
Integrating FFMpeg in Native Android Application with C++ results in bunch of errors [closed]
I need to integrate ffmpeg in my android app, i don't want to usee ffmpegkit as that is not properly maintained, i cloned ffmpeg-android-maker and then ran ./ffmpeg-android-maker.sh it created build ...
3
votes
2
answers
140
views
What is "void (0)"?
I know that (void)0 is a no-op in C/C++.
However, when I was looking through the code in <cassert>, I saw void (0).
I guess it's something like int (0) or int{0}.
I also tried void{} and it ...
0
votes
0
answers
87
views
How does copy-on-write ensure the thread safety?
When I was looking for how to implement copy-on-write in C++, I saw the implementation as below:
#include <iostream>
#include <string>
#include <memory>
using namespace std;
struct ...
0
votes
1
answer
119
views
Undeclared identifier 'format': where's std::format?
I wrote a minimal fmt.cc program:
#include <format>
#include <iostream>
using namespace std;
int main() {
// Desired output: ` 1`
cout << format("{:2}", 1) <&...
2
votes
0
answers
58
views
How can you create, partition, format a VHDX disk, and assign it a drive letter?
I'm trying to programmatically create a VHD/VHDX and perform the same "steps" seen on the following vbscript snippet, using C++, WINAPI and without relying on diskpart:
...
-9
votes
0
answers
112
views
Rectangle packing around center point [closed]
Edit: The question is about "minimum-area rectangle packing" algorithm - with the difference that rectangles are grouped "around the center point" instead of inside of a bin.Image ...
0
votes
0
answers
18
views
is it possible to edit existing CMake targets in CLion from the UI?
I'm using CLion 2024.2.3
By using the IDE and studying the documentation I still haven't found a way to edit CMake targets from the UI. I would like to be able to add/remove/change targets for ...
0
votes
1
answer
64
views
Ifstream creating an extra element at the beginning of a list
I have a file named "reservation.txt" which is used to save two classes: Customer and Motorcycle. Each member variable is saved in a new line and the classes are separated with an * like ...
1
vote
0
answers
35
views
Trouble running client and server program with docker
i really dont know what to do anymore i sat down with gpt for 4 hours and at this points its just reapiting the same steps that doesnt slove my problem
docker-compose file:
services:
server:
...
1
vote
1
answer
96
views
Which sort of UB do I have here, deleting array of operator new[]?
Given the following code involving operator new[] and the various wrong versions of delete:
#include <iostream>
class Test {
public:
Test() { std::cout << "Test()\n"; }
...
0
votes
0
answers
23
views
while using amqp qpid proton a thread_local initialized when creating a stack object is crashing my thread when I start it a second time
I'm trying to understand the below crash and cannot get my head around why/if the thread_local has something to do with it.
Here is how the crash occurs, how I fixed it and my incomplete understanding ...