g++ How to get warning on ignoring function return value

Since C++17 you can use the [[nodiscard]] attribute.

Example:

[[nodiscard]] int bar() {
  return 42;
}

Leave a Comment