> For the complete documentation index, see [llms.txt](https://wiki.hanzheteng.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.hanzheteng.com/development/c++/c++-debug.md).

# C++ Debug

## Debug FAQ

### error: if condition proceeds with a bool variable that is false

```cpp
fake_indices_ = false; // member variable initialized somewhere else

bool MultiviewGICP::initCompute() {
  std::cout << "fake_indices_ = " << fake_indices_ << std::endl;
  // this prints 0, and confirms that fake_indices_ was indeed initialized as false
  if (fake_indices_) {
    std::cout << "we are getting here." << std::endl;
    // the weird thing is that this line of code gets printed out,
    // meaning that we reached this code block, suppressing the if condition
  }
  // the root cause of this problem was the missing of the return statement below,
  // which is required of this function.
  // Without it, program proceeds with whatever code being compiled in the memory.
  return true;
  // if you put directly "if (false)", the above code block will not be executed,
  // since they may be optimized out during compilation.
}
```

### error: variable or field declared void

```cpp
// for example it happens in this case
void initializeJSP(unknownType Experiment);

// another example (due to the missing 'typename' keyword)
template <typename PointT>
void func(pcl::PointCloud<PointT>::Ptr& cloud) {} // error
void func(typename pcl::PointCloud<PointT>::Ptr& cloud) {} // correct
```

reference: <https://stackoverflow.com/questions/364209/variable-or-field-declared-void>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.hanzheteng.com/development/c++/c++-debug.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
