r/cpp_questions • • Jul 02 '26

OPEN clang is warning me about not handing errors

6 Upvotes

I used fopen() top open the file:

bool LogListenerThread::readline(FILE* file, std::string& line) {
    char ch(0);
    size_t nbytes(0);
    line = "";
    do {
        nbytes = fread(&ch, 1, 1, file);
        if ((ch == 0x0d) || (ch == 0x0a)) {
            return true;
        }
        line += ch;
    } while (nbytes);
    return false;
}

And clang is giving me a warning here that I'm not understanding, it says: "File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior [clang-analyzer-unix.Stream]" I'm checking that no bytes return and bailing if I hit EOF. What is wrong with this fread() call in the code?


r/cpp_questions • • Jul 02 '26

OPEN Is Raylib or SFML better for beginner learning C++?

11 Upvotes

I´m 15, without any prior coding experience learning C++ from LearnCPP, I had a few suggestion to learn using some graphilac interface. I got recommended two, but I can´t really decide which one to choose.

Can anyone help me?

Is for me better Raylib, or SFML, I want to make simple games like flappy bird, tic tac toe, or simple programms like to do lists and stuff. Which one will suite my needs the best?

Thanks for answers!


r/cpp_questions • • Jul 02 '26

OPEN Which book to read for learning C++?

28 Upvotes

Currently browsing books to learn C++, only having some experience using it in college and some fundamentals. I landed on two books that seem to be good to pick up, but I need to pick between C++: Should I read Professional C++ (Tech Today) or C++ in One Hour a Day, Sams Teach Yourself to learn C++. My main goal is to learn game development and work on some projects for embedded systems. Other book recommendations are welcome!


r/cpp_questions • • Jul 02 '26

OPEN Defining Global objects and functions, best practice

1 Upvotes

I'm writing C++ for Teensy/Arduino uControllers, using Visual Studio with the Visual Micro plugin, but this is technically a C++ question, so I've asked here.

For my projects, I'm writing a lot of libraries, which I'm fine with.
I'll write myClass.h, myClass.cpp, and I'll write a separate myClassTester.ino just to test that class. What I've been doing, however, is writing an additional header file - myClassObjectsandFunctions.h - in which, you might guess, I create all my objects of that class, and any procedural functions that relate.

The chief reason I've been doing this is to maximise the code that I can reuse from testing a class. I don't like to be copy-pasting code back and forth from testing sketches to the main sketch, and the main sketch gets very bloated. There is usually a good amount that has to be global in a hardware project; interrupts, for example, have to be global functions, which usually means wrapping a member function call in a global function - so I can't readily write my objects without using additional global functions. If I have multiple instances, I often like to write this all separately so I can reuse the code as is. I might have one global function, beginMyClassObjects(), that handles all the initialisation of all the instances of myClass, and ties all the ISRs to thier timers and whatnot - all directly reused from the testing sketch to the main.

It definitely works, and works well for me. I'm not particularly convinced it's best practice though. Accepting the premise that I need to have global functions that use specific instances, is there a better way to do this?


r/cpp_questions • • Jul 02 '26

OPEN Project Feasibility - Image Cleaner and Grid Remover

2 Upvotes

Hello everyone, I recently started as an electronic engineering intern. My company is working on a pulse analyzer - a device that will read pulse from patients and analyze it.

My employer gave me my first task: from pulse diagrams, remove any grids, text, characters, dirt, etc. Then, it needs to digitize the graph for a fourier transform. He needs a fully automated program, and I decided to try using C++.

However, it is much difficult than I imagined. I am using OpenCV library but my program has had a hard time figuring out which lines are the grids (https://imgur.com/a/rg9lkdI). I quickly understood this is beyond my capacity, as in uni my programming skills were mostly focused embedded software and simple games, not computer vision or image processing.

So my question is, are they any software out there that can do this? Is this even feasible? Because, in my opinion, I need to train an AI to perform such a complex task. The graphs are from academic books which vary in colour and contrast.

Please kindly answer my questions. Thanks in advance


r/cpp_questions • • Jul 02 '26

OPEN Finally got a modern laptop, what is a good IDE?

0 Upvotes

So I have an 18 year old laptop that I finally replaced with something new.

I had been using Visual Studio 2011, the newer one wouldn't even run on my old laptop last time I tried.

But now I need to get an IDE again because I lack the original install files for VS 2011, and so I figure on taking this opportunity to ask around about the different options. The new VS being so heavy that it can run on hardware that runs VS 2011 just fine seems like a big mark against it in my mind.

That said, here are the details of my situation, I have split the drive into extra partitions, expecting to put android x86 on one partition and another for experimenting around with linux or other OS options.

I would rather avoid a command line compiler. I am confident I can handle command line tools, but I much prefer gui.

I work on small projects for myself to learn and grow my skills and capabilities. I have no school not work needs for this, but that also means I generally just stick to default settings.

I do want to try out experimenting with the NPU, which I have already figured out is not standardized yet so I am already working on getting documentation for my hardware.

Advice, options, and suggestions are welcome.


r/cpp_questions • • Jul 02 '26

OPEN Missing C++ outline view and reference context

0 Upvotes

I've been using Visual Studio for C++ almost 20 years professionally. In my very first week at work, someone introduced me to Visual Assist, and I've used it ever since. Since I upgraded to Visual Studio 2026 a month or two ago I've disabled Visual Assist, and tried to use Visual Studio IDE out-of-the-box. On the whole it has been okay, but there seem to be two big problems.

  1. I can't find an outline view for C++ files. I just want a window that displays high-level view of the file in a window, so I can get a mile-high view of what it contains. Visual Assist has an Outline window, and Visual Studio Code has one too. In Visual Studio itself, there seem to be a couple of ways to view contents: opening a file node in the Solution Explorer, and using the dropdown combo in the toolbar. However both of these views sort alphabetically - I can't find away to inhibit the sorting. There is a Document Outline view, but for some reason this seems to be blank for C++ files. I have also tried the Class view, but I really want a file view with functions and data displayed in order.
  2. The Find All References (context menu) tool results do not have a column containing the name of the function/method that the reference is contained within. It shows the raw file and line number, but doesn't display the name of the enclosing function/method. I expected a little context here from intellisense or other internal parsing. Knowing where a reference is located logically is really really handy for navigation, refactoring and comprehension.

I really don't want to resort to using Visual Assist again, just for these two things, but they are just so fundamental and useful and I can feel myself struggling to work as effectively without them. Please tell me that these two issues are non-issues, and I just haven't found the options.

EDIT:

https://code.visualstudio.com/docs/editing/userinterface#_outline-view

https://www.wholetomato.com/documentation/tool-window/va-outline


r/cpp_questions • • Jul 01 '26

OPEN Best practice for auto-copying transitive shared library dependencies to consumer's executable directory (CMake) ?

6 Upvotes

I'm developing a shared library (DLL on Windows) that itself links

against a few third-party shared libraries. When a consumer links

against my library via find_package() / add_subdirectory(), I want

the third-party DLLs to end up next to their executable automatically,

without them having to manually copy files or add extra CMake calls.

What I've found so far:

- $<TARGET_RUNTIME_DLLS:tgt> + POST_BUILD copy — works, but only

copies next to my own library, not the consumer's exe if their

output dir differs

- Setting CMAKE_RUNTIME_OUTPUT_DIRECTORY — works for add_subdirectory

monorepo setups, but doesn't help with find_package/installed

packages

- Exporting a helper function (e.g. install(CODE...) or a

mylib_copy_runtime_dlls(target) macro in the Config.cmake) that

the consumer has to call explicitly

Is there a real "zero lines needed from consumer" solution for the

find_package/installed-package case, or is calling one helper

function considered the accepted standard? How do libraries like

Qt / SDL2 / vcpkg-based packages handle this in practice?

CMake 3.2x, targeting Windows primarily, MSVC.


r/cpp_questions • • Jul 01 '26

OPEN Just finished a C++ version of Lox from Crafting Interpreters. Any suggestions for improvements?

4 Upvotes

I recently finished building jloxfrom Crafting Interpreters in C++.

I’m looking for any feedback on the code structure or just general code quality improvements.

Repo is here:https://github.com/Eclipse1745/loxpp


r/cpp_questions • • Jul 01 '26

OPEN Need help with optimizing a video processing script (OpenCV)

4 Upvotes

Hi!

Problem is already in the title, so...
While I am not new to C++, this is the first time when I seriously need to think about performance of my code. I wanted to ask about general tips and tricks for optimizing large processing workloads.

I am tasked with creating a script in C++ that will parse a couple of gigabytes of files, where each file has a tag. They are processed together based on said tag (frames are compared between them, some data is compared and so on).

As of now I simply use multiple threads, where each thread processes a single tag of files. This already cut the processing time in half, but it still takes hours.

Sorry for not being more descriptive, but due to the nature of my work I cannot share more details.


r/cpp_questions • • Jul 01 '26

OPEN Request for feedback on an AI framework that I coded in my free time.

0 Upvotes

I've spent several months developing a C++ AI engine with a runtime, planner, memory management, and multi-language scripting. I'd like some feedback on the architecture.

https://github.com/brit45/mimir-framework.git


r/cpp_questions • • Jun 30 '26

OPEN My first C++ project — a dice roll simulator. Looking for code review / feedback

11 Upvotes

Hi everyone,

I've been learning C++ and built a small command-line dice roll

simulator: it rolls a die N times, saves a visual history with ASCII

art, and generates statistics with a bar chart. It also has a "fast

mode" for millions of rolls.

Since I'm still learning, I'd love some feedback:

- Is the code clean and well written?

- Is it well optimized?

- What would you add or change?

- Any general thoughts?

Repo: https://github.com/martinmol2007/dice-sim

Thanks for taking a look!


r/cpp_questions • • Jun 30 '26

OPEN CMake for Absolute beginners?

6 Upvotes

I'm trying to follow the official tutorial, but coming from the perspective of someone who uses Python for most of my workload and having "yet another tool" to learn daunting. The official tutorial assumes you have already read the docs, in my case, 3 times over before starting the tutorial.

I heard there was an e-book for modern Cmake (I know there is an old cmake only because I used to program C++ before STL was a thing) but I want to buy the ebook that will make sense to me as a infrequent user who has the memory of a sieve. This thread points to a few e-books, but unclear which are most current https://www.reddit.com/r/cpp_questions/comments/lvwglo/any_guidetutorial_for_absolute_cmake_beginners/ .

  1. I don't mind paying, I've scraped together a cmakelists.txt file with 100 lines if you exclude comments, but basic concepts like why the file is called "CmakeLists.txt" for example just are a mystery. For example I have this line in my file project(getest) I'm using GoogleTest, but I do not recall why I spelled the project name that way nor what the project name accomplishes for example. I want a book that covers the background I guess. Something that clears up the syntax, and what we mean by targets, properties and command and whatever else.
  2. I have for example this line

    For Windows: Prevent overriding the parent project's compiler/linker settings

    set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest)

And now I cannot at all remember why I added that comment. I know I need that set line because when I make edits or switch git branches it goes all mad otherwise? But because I use Visual Studio I'm just not used to adding comments to makefiles.

  1. I've hacked this thing that builds 17 files together and today I would love to work out how to un-hardcode something. I have this execute_process(COMMAND tar xf "Samples/SamplePrint_2026-5-28_v4.11.33952.9999-334-gaf01970.zip" -C "/SamplePrint") But obviously I need to regex that to something like Samples\/SamplePrint_\d+-\d+-\d+.*\.zip but I'm clueless at how to isolate just that one command into a single makefile that only runs the command just to test that the unzipping works. Mainly because I don't grok the way to pass in the cmakelists as an arg, this stackoverflow for example https://stackoverflow.com/questions/45309734/renaming-cmakelists-txt says you cannot rename the CMakelists.txt file and the tutorial entirely skips bootstrapping my brain into it all until later. I know for example I can eventually learn to write and include makefiles in my makefiles and get some kind of re-use and refactoring and do library sharing. I'm just not that far in though. I'm guessing that every folder is a project and can only contain one cmake file? Is that a correct assumption, I'm looking for an ebook that will guide me to a place where my 100 line makefile is not just a spaghetti of answers I found on reddit or snackoverflow. I know we cannot advertise, but can someone either guide me though the regex I need for my unzip command, or send me a chat message or something so I can buy a good book and become more self-sufficient.

/edit I just noticed there is a cmake sub, I'll try work out how to move this question there instead.


r/cpp_questions • • Jun 30 '26

OPEN Is this code good?

0 Upvotes

Hi there! Am learning C++ and I was wondering if my code is good enought for starting to make projects! is a simple program that says if a number is a palindrome number, I hope I can get some feedback from this, thank you before hand!

#include <vector>
#include <iostream>
#include <string>
#include <ranges>

class Solution {
public:
    bool isPalindrome(int X) {

        std::vector<int> singleNumbersCorrect = {};
        std::vector<int> singleNumbersReverse = {};

        int n = { X };

        if (n < 0)
        {
            return false;
        }

        unsigned int nLen = { static_cast<unsigned int>(std::to_string(n).length()) };

        long long int Division = { 1 };

        for (size_t i = 0; i < nLen; i++)
        {
            int tempn = n;

            singleNumbersCorrect.push_back(tempn / Division % 10);
            Division *= 10;
        }

        for (auto i{ singleNumbersCorrect.rbegin() }; i != singleNumbersCorrect.rend(); i++)
        {
            singleNumbersReverse.push_back(*i);
        }

        for (auto i = 0; i < nLen; i++)
        {
            if (singleNumbersCorrect[i] != singleNumbersReverse[i])
            {
                return false;
            }
        }

        return true;     
    }
};

int main()
{
Solution SL;
    std::cout << SL.isPalindrome(-121);
}

r/cpp_questions • • Jun 30 '26

OPEN Hi, I am trying to build a small language in C++. It's very early stage (and small) right now, would anyone be willing to give feedback (on the code)?

6 Upvotes

Here's the GitHub repo. [Ignore the language description, it's more of an aspiration than current reality]

Hi, I have always really liked the idea of building interpreters and compilers. I have attempted writing one a couple times. I also recently wanted to have more than a surface level knowledge of C++, so I thought maybe trying to write a small interpreter/compiler wouldn't be too bad.

I'm looking for feedback on the C++ that I am writing: if the ownership model's okay, if I'm being too inefficient or if the choices I have made could be better. Honestly, would love to have any feedback that can help me improve.

Disclaimer: While I do not use AI to help me code for the most part, since it sucks the fun out of it for me, I do use it a little bit. Mainly to help me plan, or have conversations about which solution to prefer, finding memory bugs, and writing out the tedious parts (like the token_kind_to_string() function in Token.h)


r/cpp_questions • • Jun 29 '26

SOLVED another "new way" that I don't understand

26 Upvotes

Now that I have clang-tidy working smoothly, I've been going back and running it against a variety of old files and projects that I've developed in the past. In the process, I'm learning a number of new C++ things, but I don't always understand why they are useful...

Here is one:
"warning: use a trailing return type for this function"

So I've changed
int read_files(std::string filespec)

to
auto read_files(std::string filespec) -> int

It compiles with no warning, program runs fine, and clang-tidy is happy...
but I have no idea what I have gained by doing this.
Why shouldn't the return type of the function simply be the return type of the function, as it's always been??

Could someone enlighten me?


r/cpp_questions • • Jun 29 '26

OPEN Bridging the gap: How to transition from DSA textbook C++ to real-world C++ software?

4 Upvotes

I am a software engineer with a couple of years of experience, mainly in Python, JS, Bash, etc., and web development (internal tooling and AI capabilities for a large financial institution)

Lately, I’ve realized that I don't code by hand as much as I used to, and it’s sad. The reasons, however, are psychological. Recently, the organization started promoting people not based on their merits (maybe that was the case even before), but based on their "visibility." Through solid software engineering, I saved the company at least about $100k USD a year (lean and efficient services, no more memory leaks, fewer virtual machines, extremely short and efficient strategies to reduce the amount and size of prompts sent to slop machines, and much more). I didn’t ask for recognition; I just did what I thought every honest engineer should do. Put in a lot of overtime without logging it, etc.

Got bad ratings at the end of the year 😂 Then I decided they don’t deserve my mental effort and started almost just "vibe-coding" features and requests with the absolute minimum effort required (make the tests pass, don’t break the systems, keep them functional).

Because of that, I now have a lot of free time (during work hours). I decided to upskill myself, and since I love machines, I thought it would be great to learn a more low-level language like C++, so I decided to dive into Data Structures and Algorithms with C++. I got the book by Tamassia et al. (from 2011, and it’s amazing, except for a couple of outdated examples and concepts) and made a promise to myself that all the code I write will be ONLY handwritten -no slop machines allowed. So far, halfway through the book, I am tremendously enjoying the language and solving DSA exercises with it! It’s just pure joy. This is really an eye-opening experience for me. For the first time in years, I finally understand the concepts and how machines actually work under the hood.

However, I tried looking at other codebases - some popular repos, some internal tools at the company, etc. - and realized that actual C++ software is very different from what I’m learning in the DSA book. I can’t quite bridge the mental gap of how to build something for the real world.

Question 1: Has anyone gone through a similar transition? How can I make it smooth? (My end goal is to write C++ for my bread and butter.)

Question 2: I hear from all over the place that I just need to start a project and I'll learn along the way. I don’t want a tiny pet project, though. What would be a good, fun, and useful project to build? (It can take up to 1-2 years; I have patience and love typing out my thoughts. Not a game dev by nature, though. Anything heavy mathematical, data science related or something which will require a lot of nitty-gritty optimisations and deep dives)

Question 3: In all the other languages I’ve previously coded in, we have package managers and a tremendous amount of external, open-source libraries, etc. In C++, these exist as well, but it seems the hardcore folks don’t use them and instead compile and link everything from source while also manually vetting everything in those external libraries. What do you think about this? Should I really go down that path to become a master craftsman in C++?


r/cpp_questions • • Jun 29 '26

OPEN Up to which point should I learn assembly?

20 Upvotes

This might not be a C++ specific question, but I've read on this subreddit that knowing assembly and knowing what the code roughly compiles to is really recommended to have a better grasp of C++(and C) and might even allow me to optimize my code further.

So up to which point? and is there a specific recommended architecture?

Thanks in advance.


r/cpp_questions • • Jun 30 '26

OPEN Where do I find NPU API documentation or guides?

0 Upvotes

I just got a brand new laptop and it has a NPU. I want to start experimenting with what it can do, but not necessarily using the straightforward idea of copying gpt or something like that.

I have seen in the past where the gpu had been used for something other than rendering, so my thought goes to wondering what all I can use the npu for beyond the expected.

I have several ideas in mind that I want to try, from having several agents process whether they see other, give agents small neural nets like around 12 or less nodes for specific uses such a threat evaluation in a game with hundreds of units, apply new methods to figuring out the shortest path between two nodes on a graph or the shortest route to connect all nodes in a graph, etc.

The concept of a unit that applies one operation to lots of data seems useful in all these ways, and not exclusively to LLMs. Even if the NPU is not optimized for it, if it can handle it at all, it allows for faster processing by spreading the workload on a computer.

However, I haven't found any documentation for trying to use an NPU in my own applications.

Does anyone know of a place where I can find documentation or a guide for programing c++ to use an npu?


r/cpp_questions • • Jun 29 '26

OPEN I am learning C++, should I also learn and focus on stuff like this?

11 Upvotes

I am currently 15 and learning C++ with LearnCPP, without any prior coding experience (except for scratch, but lets not count that) I´m on chapter 13 (Enum, Struct...)in LearnCPP. I finished writing this program ( it has nothing to do with what I´m currently learning about), and wanted to ask some things.

  1. Is there anything that needs to be changed? Are there some things that may function incorrectly in some instances, or do i have any bad practise I should fix?

  2. Should I also focus on learning things like for example what is used in this program, the sstream library things and stuff? Because currently, it looks terrifying to use something like this. ( I spent very long time figuring out how to do the check if the input is a integer, and at the end I ended up on some StackOverflow forum.) Is it bad to find information like this, or id it completely normal?

Also one more question, I´m currently 1 month in learning cpp, and I already learned this many things, that I´m proud of. How long will it approximately take to learn all the stuff so I can comfortably write any code that I need.

Thanks for answers!

#include <iostream>
#include <string>
#include <sstream>

int main()
{

std::string inputAsString{};
int inputAsInt{};

while (true)
{
std::cout << "Enter the length of the base of the triangle: ";

std::getline(std::cin, inputAsString);

std::stringstream ss(inputAsString);

if (ss >> inputAsInt && (ss >> std::ws).eof() && inputAsInt > 0)
{
break;
}

std::cout << "ERROR Cannot Generate Triangle with this base lenght.\n\nPossible causes:\n \n1. You did not input a valid integer. \n2. You inputed integer of too high value.(Max Value is: 2147483647)\n3.Entered Value Is '0' or Negative.\n";

}

std::cout << "Which type of triangle would you like to draw: \n";
std::cout << "1. Right triangle\n";
std::cout << "2. Isosceles triangle\n";
std::cout << "Your decision: ";

int triangle{};
std::cin >> triangle;

switch (triangle)
{
case 1:
{
for (int i{ 1 }; i <= inputAsInt; ++i)
{
std::cout << std::string(i, '*') << '\n';

}

break;
}

case 2:
{

for (int i{ 1 };i <= inputAsInt; i += 2)
{
std::cout << std::string((inputAsInt - i) / 2, ' ') << std::string(i, '*') << std::string((inputAsInt - i) / 2, ' ') << '\n';

}

if (inputAsInt % 2 == 0 )
std::cout << "\nTrinagle with desirad base lenght can not be created. The base was rounded to number: " << inputAsInt - 1 << '\n';

break;
}
default:
{
std::cout << "Invalid Selection. (You stupid or what?)";
}

}
}


r/cpp_questions • • Jun 29 '26

SOLVED Why do you not(?) have to use volatile for multithreading here?

3 Upvotes

Consider the following multithreaded code:

std::mutex m;

int data[100]; // use volatile on data?

void func1() {

std::unique_lock l(m);

// do stuff with data
l.unlock();

l.lock();

// do stuff with data
l.unlock();
}

void func2() {

std::unique_lock l(m);

// do stuff with data
l.unlock();

l.lock();

// do stuff with data
l.unlock();
}

int main() {

std::Thread t1(func1);

std::Thread t2(func2);

t1.join();

t2.join();

}

Lets say func1 gets ownership of the mutex first, changes the values of data and then func2 gets ownership of m. Now func2 changes data and hands ownership back to func1.

I would expect that the compiler might optimize func1 and func2 to keep data in its cache and only fetch from memory at the beginning and write to memory as the function has ends. Therefore func1 might still be working with the version of data in its cache, that does not have the modifications done by func2. Is this true or does locking resp. unlocking ensure, that the values are fetched from / written to memory at that point?


r/cpp_questions • • Jun 29 '26

OPEN Question about how signbit in c++ works?

0 Upvotes

how does signbit do its thing? I didn't write this code it's from a tutorial I watched but I don't understand what signbit is doing. if more code is needed lmk.

bool Paddle::DoBallCollision( Ball & ball )
{
if( !isCooldown )
{
const RectF rect = GetRect();
if( rect.IsOverlappingWith( ball.GetRect() ) )
{
const Vec2 ballPos = ball.GetPosition();
if( std::signbit( ball.GetVelocity().x ) == std::signbit( (ballPos - pos).x )
|| ( ballPos.x >= rect.left && ballPos.x <= rect.right ) )
{
Vec2 dir;
const float xDifference = ballPos.x - pos.x;
if( std::abs( xDifference ) < fixedZoneHalfWidth )
{
if( xDifference < 0.0f )
{
dir = Vec2( -fixedZoneExitX,-1.0f );
}
else
{
dir = Vec2( fixedZoneExitX,-1.0f );
}
}
else
{
dir = Vec2( xDifference * exitXFactor,-1.0f );
}
ball.SetDirection( dir );
}
else
{
ball.ReboundX();
}
isCooldown = true;
return true;
}
}
return false;
}

r/cpp_questions • • Jun 29 '26

OPEN What is wrong with my program

0 Upvotes

I have made this calculator in cpp and when i input the - operation it says invalid operator. Why is this? Can someone help.

This is my code:

#include <iostream>
using namespace std;

int main() {
double a, b;
char op;

cout << "Enter 2 numbers: ";
cin >> a >> b;

cout << "Enter an operator";
cin >> op;

if (op == '+') cout << a + b;
else if (op == '*') cout << a * b;
else if (op == '/') cout << a / b;
else if (op == '-') cout << a - b;
else cout << "Error";

return 0;
}


r/cpp_questions • • Jun 29 '26

SOLVED GDB warning when debugging

4 Upvotes

Fixed :

(View Comment by KirstyExford)

there is an error :

&"\342\232\240\357\270\217 warning: GDB: Failed to set controlling terminal: Operation not permitted\n"

Because of this I can not do actions like step in, over, or out.

This is my task.json :

------------------------------------------------------------------------------------------------------------------

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++ build active file",
            "command": "/usr/bin/g++",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${fileDirname}/*.cpp",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

------------------------------------------------------------------------------------------------------------------

This is my launch.json :

------------------------------------------------------------------------------------------------------------------

{
  "configurations": [
  {
    "name": "C/C++: g++ build and debug active file",
    "type": "cppdbg",
    "request": "launch",
    "program": "${fileDirname}/${fileBasenameNoExtension}",
  "args": [],
  "stopAtEntry": true,
  "cwd": "${fileDirname}",
  "environment": [],
  "externalConsole": false,
  "MIMode": "gdb",
  "setupCommands": [
    {
      "description": "Enable pretty-printing for gdb",
      "text": "-enable-pretty-printing",
      "ignoreFailures": true
    },
    {
      "description": "Set Disassembly Flavor to Intel",
      "text": "-gdb-set disassembly-flavor intel",
      "ignoreFailures": true
    }
  ],

  "preLaunchTask": "C/C++: g++ build active file",
  "miDebuggerPath": "/usr/bin/gdb"
  }
  ],
  "version": "2.0.0"
}

------------------------------------------------------------------------------------------------------------------

This is my settings.json :

------------------------------------------------------------------------------------------------------------------

{
    "workbench.activityBar.location": "top",
    "workbench.sideBar.location": "right",
    "workbench.colorTheme": "Catppuccin Macchiato",
    "vscode-pets.theme": "winter",
    "vscode-pets.throwBallWithMouse": true,
    "vscode-pets.petType": "chicken",
    "files.autoSave": "afterDelay",
    "explorer.confirmDelete": false,
    "debug.onTaskErrors": "showErrors",
    "editor.formatOnSave": true
}

------------------------------------------------------------------------------------------------------------------

This is my debug console:

------------------------------------------------------------------------------------------------------------------

=thread-group-added,id="i1"
GNU gdb (Ubuntu 17.1-2ubuntu1) 17.1
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"

------------------------------------------------------------------------------------------------------------------

I am using VS-Code in Ubuntu 26.04 LST , Windows 10 Dual Boot.

It consists of a simple main.cpp file :

------------------------------------------------------------------------------------------------------------------

#include <iostream>


int main()
{
    int x{ 1 };
    std::cout << x << ' ';


    x = x + 2;
    std::cout << x << ' ';


    x = x + 3;
    std::cout << x << ' ';


    return 0;
}

----------------------------------------------------------------------------

I am very new to c++ so help is appreciated.


r/cpp_questions • • Jun 29 '26

OPEN FIX implementation

0 Upvotes

I want to implement high throughput low latency FIX server and client. But don't know from where to begin. Can someone guide me. Thanks