Questions tagged [c++]

C++ is a general-purpose programming language. It was originally designed as an extension to C, and keeps a similar syntax, but is now a completely different language. Use this tag for questions about code (to be) compiled with a C++ compiler. Use a version specific tag for questions related to a specific standard revision [C++11], [C++17], etc.

0
votes
1answer
29 views

Is this code doing multiple instantiations and how to avoid it?

Suppose I have some code that looks like follows Convert.hpp #pragma once #include <cassert> class Converter { public: template <typename T> static inline void to_type(const char* ...
0
votes
0answers
13 views

Low FPS with DirectX 9?

I have a DirectX 9 Tool, that creates an external overlay to a Game. But for any Reason i have only around 10-15 FPS with that DirectX 9 tool, while the Game has 150 FPS. My PC is more than good ...
0
votes
0answers
13 views

Cannot directly convert number to hex null-terminated string, has to convert to std::string then use .c_str()

I've tried to convert an integer to a hex null-terminated (or "C-style") string but I cannot use it with printf or my custom log function. It only works if I convert it to an std::string then use ....
0
votes
0answers
11 views

Get access to GpuMat channels

I am working on raytracer. I wanted to optimize my code by saving data of each pixel in Mat, using GPU. For now, I save pixel values in buffer "fb" which is a vector of three values (RGB): ...
0
votes
2answers
33 views

Converting std::vector<char> to char* causes defective characters

I have a function in my code called buildPacket that takes some parameters, and converts them into a char* and adds them together using a std::vector<char> and at the end returns the result as a ...
1
vote
3answers
33 views

How to invoke a lambda template?

I was able to compile the following code with gcc: template<typename... Pack> auto func(Pack... x) { return (x + ...) ; } template<typename... Pack> auto lamd = [](Pack... x) { ...
0
votes
0answers
22 views

Writting a parser for formatted text in C++

I'm trying to write a parser for a formatted ASCII file with blocks like this .START_CMD info1 info2 info3 * additionnal_info1... .END each field can be a string, an integer, a double, etc wrote in ...
-4
votes
0answers
12 views

How to code in MPLAB to connect ESP8266 with Firebase? [on hold]

I want to connect Firebase with a microcontroller through ESP8266 using MPLAB IDE. I am not using any Arduino.
0
votes
0answers
14 views

Crash when Interacting with Dynamic QML UI Elements

I am creating QML components in c++; they consist of pages being added to a SwipeView, along with corresponding TabButtons to an associated TabBar. Each page has a 'card' which consist of a label and ...
-2
votes
0answers
27 views

How to manage different namespaces when passing pointer to a method

I'm working on a program with different namespaces. But When I call a method of a class in namespace A that needs a pointer of an object in namespace A::B but created in A, I get an error. Here is ...
2
votes
0answers
16 views

Problem compiling move.hpp with Visual C++ 2015

I am trying to compile <...\boost\1.70\include\boost\thread\detail\move.hpp> with Visual C++. However, I got an error stating "pointer to reference is illegal" If I take a look at the source code ...
0
votes
0answers
41 views

Ideas on getting rid of boiler plate code

My problem is very specific. I have the following requirement, I need to set member variables that exist in child class from parent class, for several reasons. My plan is to pass a function pointer of ...
-1
votes
0answers
28 views

Make images “from scratch” using c++. Any book or other recommendations? (except libpng, etc.)

Even though I am not studying computer science, I would like to know how images work. Basically, what I am looking for is how to "write" an image using fstream ios::binary or something like that (no ...
0
votes
0answers
11 views

Sending 2D arrays through TCP in SFML C++

I'm designing a simple Battleship game using SFML. The player's grid is assigned to a 2D array int playerGridd[10][10] and vice versa. I tried to use SFML networking to send playerGridd through TCP, ...
0
votes
0answers
22 views

Check if ISO 8601 date format is valid in C++

The date time in the ISO 8601 format is YYYY-MM-DDThh:mm:ssTZD How do I check if the date 2018-12-25T12:00:00+04:00 is valid in C++. I tried using strptime but gives an invalid date result.The date ...
2
votes
1answer
46 views

writing to std::atomic after converting to char*

Sorry if my doubt is too naive. But I have a difficulty in typecasting std::atomic to char* type. Is casting from std::atomic to char is valid? Can I write to such type casted variable. I am sure ...
-2
votes
0answers
38 views

Why should you declare a copy constructor?

Why is it recommended that you explicitly declare a copy constructor,even when the compiler makes a public copy constructor when you use objects as parameters , use objects as a return value or even ...
0
votes
0answers
13 views

How to create OpenGL + GLFW desktop wallpaper window?

I want to create GLFW window in wallpaper layer, but attributes (like _NET_WM_WINDOW_TYPE_DESKTOP) not work and I have a normal window above another. I use native (glfw3native.h) functions to take ...
0
votes
3answers
58 views

Spacing for Right aligned Triangle

Assignment: Write a program that prompts the user for an integer value representing the height of a triangle. The program should then print out a triangle of O’s of that height, with a vertically ...
2
votes
2answers
30 views

lost rvalue references if forward_as_tuple result is stored in variable before using it in std::apply

While working on a project I encounter a situation std::apply does not forward rvalue references from std::tuple created by std::forward_as_tuple *IF* resulting std::tuple is stored in a variable! ...
0
votes
1answer
48 views

Finding a repeated element in an array

I have come up with this problem on my own. I am only a beginner and learning C++ currently. Q. Find all the repeated elements in an array and provide their index number. I am trying to solve this ...
0
votes
1answer
17 views

PInvoke only works in 64 bit, when returning a struct [duplicate]

I have the following C++ code, that compiles to a dll: typedef struct _RGB { unsigned char R, G, B; } RGB; extern "C" __declspec(dllexport) RGB __stdcall TestMethod1() { RGB rgb{1,2,3}; ...
0
votes
0answers
15 views

When gdb the coredump file of mangosd with docker, it shows question mark

Current behavior: the function name be showed as question mark Expected behavior: show the valid function name Steps to reproduce: mangosd(release) coredump log Next game event check in 120 ...
0
votes
0answers
21 views

The build tools for v141 (Platform Toolset = 'v141') cannot be found

I am writing code to load c++ dll from electron. I have installed Visual Studio v141 tools but when running npm install I get the following error: "The build tools for v141 (Platform Toolset = 'v141') ...
0
votes
0answers
12 views

Combining Multiple Events in Boost Metastate Machine

Is there a way to combine multiple events in the functor front end for boost meta state machine? I'd like to do the following: // Start ------- Event------ Target-- Action--- ...
0
votes
0answers
9 views

QMYSQL Driver not loaded using Qt 5.12.0 in Ubuntu 16.04

Hi I'm trying to build a program that connect on MySQL, i have this error "QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7" But i already "...
0
votes
0answers
15 views

Protocol https not supported or disabled in libcurl in Redhat Linux 8

I have an C++ application which is using curl 7.61.1 version. while trying to connect to device using ssl I get this error: "Protocol https not supported or disabled in libcurl" although the default ...
0
votes
1answer
35 views

Code to find peak index of mountain array

You may recall that an array A is a mountain array if and only if: A.length >= 3 There exists some i with 0 < i < A.length - 1 such that: A[0] < A[1] < ... A[i-1] < A[i] A[i] > ...
-2
votes
0answers
24 views

How can I make a Windows 10 C++ program exploitable to buffer overflows with stack cookie?

I am building test cases to learn software security , but I want to create a stack cookie bypass via SEH. this is my code. #include <cstdio> #pragma comment(lib, "Ws2_32.lib") #pragma warning(...
0
votes
0answers
15 views

Converting DLL to LIB

I know this has been asked a lot of times but somehow after trying all these solutions, none seems to work for me. I am trying to build Amazon Alexa AVS SDK app for use in Visual Studio. I can ...
0
votes
0answers
13 views

Why msvc can't find “spdlog/spdlog.h” header?

Code Repository: https://github.com/fastype/fastype I use Windows 10 with Visual Studio 2017. All the cmake config seems right, while not working for spdlog headers. The error messages are: cannot ...
0
votes
0answers
11 views

Access C++ application from Node JS via Node FFI - Read some data as bytes and write it to a file

I am writing a Node JS wrapper for C++ program using NODE-FFI. I don't have access to the C++ source and It's in the DLL form. There is a method to read some data until it finished and write to a ...
0
votes
0answers
9 views

How can I get metadata (key length value) in the video in c++?

I'm trying to make a map from the video. and I want to use KLV metadata in MPEG2-TS video. How can I impelement klv class and get the metadata from the video? I found this github project: https://...
1
vote
2answers
69 views

C++ recursive initialization of vectors using iterators produce inconsistent results

I was trying to practice C++ iterators by defining the very common mergesort algorithm when I encountered inconsistent program behavior. My question is NOT how to implement mergesort (which I both ...
0
votes
1answer
46 views

How to fix the next thread to be more correct? Using Pthread

I'm investigating the use of PThread. The main process opens the camera and gets a matrix. Then calls the thread that running job in robot and I want it to be parallel. Basically it works and runs. ...
0
votes
0answers
17 views

Fast element-wise access in Eigen::SparseMatrix in Latent Dirichlet Allocation

I am implementing Latent Dirichlet Allocation (LDA) in Rcpp. In LDA, we need to deal with a huge sparse matrix (e.g. 50 x 3000). I decided to use SparseMatrix in Eigen. However, since I need access ...
0
votes
0answers
21 views

How to highlight erros in visual studo code editor for c++ language?

I installed C/C++ IntelliSense version of 0.23.1 in visual studio code version of 1.35.1 in Ubuntu 18.04, and could not able to see error highlighting in the editor for c++. I have manually changed ...
0
votes
1answer
33 views

Any way to use variables as rules and prerequisites in GNU Make?

I'm trying to set up my Makefile in such a way that I can define all of the inputs and outputs in some variables so I only have to write a single rule to compile the project. This allows me to ...
1
vote
2answers
63 views

Can you declare a member function and make them do different things?

I've tried numerous ways to go about this but none of them worked. What I'm trying to achieve is this. I have a class like this. class Auton { public: int slot; const char * name; void ...
2
votes
2answers
75 views

I cannot catch and handle floating point exception?

I try to write a simple program to practicing Expection of C++, but I cannot catch and handle floating point exception? This is my code. #include <iostream> ...
0
votes
0answers
34 views

Char Array in Visual Studio c++ forms application [on hold]

I'm trying to make a forms application in visual studio c++. I want to declare a char array that can be used by any part of the form, like this char ab[] = "aaaa"; I can't put it in the button code, ...
-1
votes
0answers
27 views

Odd compilation issue with windows x86 binary [on hold]

I am creating some test case (simple overflow) using the following, but when I tried to check if its works, I got this, however it should be overwritten on EIP. What am I doing wrong with the ...
0
votes
0answers
49 views

Saving data to a text file (M.F.C)

I have a dialog called SettingDlg, and its purpose is to create a different dynamic row of controls for me on run-time. When the work is done, I want to SAVE some data like (number of controls, ...
0
votes
0answers
27 views

How to send double-type data via TCP/IP Winsock

I'm trying to send sensor data (double type) from client to server via TCP/IP (Winsock). In theory, after connected successfully, we will execute the command send(). I use 2 variables: stringstream ...
-2
votes
0answers
29 views

Byte escape sequence at runtime [on hold]

I'm trying to convert an std::string of: "\x8D\x34\x85\x00\x00\x00\x00\x89\x15\x00\x00\x00\x00\x8B\x41\x08\x8B\x48\x04\x83\xF9\xFF" to the compile-time equivalent of: (BYTE*)"\x8D\x34\x85\x00\x00\...
0
votes
0answers
16 views

How to fix the number of SIFT keypoints?

I am trying to use SIFT descriptors that are directly used for image classification. The SIFT is defined by: Ptr<SIFT> sift = SIFT::create(100). Then I expect there would be 100 keypoints to be ...
-4
votes
0answers
28 views

Building backend API using c++/python [on hold]

python/c++ to build some backend API (and set up a simple frontend in javascript/HTML) to interact with it. I don't know where to start from in terms of the backend side.
0
votes
0answers
30 views

Using a non-static object inside another class

I've looked at several examples that looked very similar to my code but have been unable to glean what they're doing differently. When used alone both my PWM and LED objects work, but when I ...
0
votes
1answer
34 views

How do I get the derived class from a interface?

While trying to create an Entity-Component-System in C++, I have faced some problems regarding by lack of knowledge on the language. With a class Entity, that holds the interface IComponent (which ...
3
votes
0answers
46 views

Java Native Interface - C++ is not waiting for java function completion

I want the functionality of the Stanford Core NLP, written in java, to be available in C++. To do this I am making use of the Java Native Interface. I have a Java object that wraps multiple functions ...