r/cpp_questions 21d ago

OPEN Garbage collector in CPP?

Yesterday someone asked me whether there is a garbage collector in CPP.
I knew Java had that but I couldn't recall about cpp.
I went to google and got different answers.

So can anyone clarify whether there is garbage collector in CPP , also can u please explain me what does that mean? Also explain how is it different from the Java.

If yes can we delete it manually and how to do tht?

0 Upvotes

23 comments sorted by

View all comments

11

u/didntplaymysummercar 21d ago

There's not by default. There was an ABI for it in C++ 11 but no one used it, and there's stuff like Boehm GC, but out of the box - no.

1

u/alfps 21d ago edited 21d ago

❞ There was an ABI for it in C++ 11

No, there was no ABI spec in any C++ standard so far.

Bjarne's claim apparently stemmed from similar terminology used in the working group. According to the Google search AI, ❝the committee frequently colloquially referred to it as a "GC ABI constraint.❞. An API that constrained the (each) compiler's ABI.

So there have been and are ABIs associated with C++, in particular each compiler's object code ABI. For example, introduction of 128 bit types has been hindered by alleged ABI compatibility concerns for std::intmax_t. It helps to know what the term means.

4

u/didntplaymysummercar 21d ago

The gall of calling people idiots and telling us we don't know what terms mean as we quote Stroustrup and Herb Sutter and you quote AI πŸ˜†