Since C++17 you can use the [[nodiscard]]
attribute.
Example:
[[nodiscard]] int bar() {
return 42;
}
More Related Contents:
- Can I make GCC warn on passing too-wide types to functions?
- Why does flowing off the end of a non-void function without returning a value not produce a compiler error?
- What is the difference between g++ and gcc?
- Selectively disable GCC warnings for only part of a translation unit
- How does #include work in C++? [duplicate]
- Compiling a C++ program with GCC
- Undefined Symbol ___gxx_personality_v0 on link
- Why does typeid.name() return weird characters using GCC and how to make it print unmangled names?
- Compiling multithread code with g++
- How to create a static library with g++?
- How to force gcc to link an unused static library
- gcc/g++: “No such file or directory”
- 😃 (and other Unicode characters) in identifiers not allowed by g++
- How to tell where a header file is included from?
- How to include omp.h in OS X?
- Linking g++ 4.8 to libstdc++
- Update GCC on OSX
- How do you disable the unused variable warnings coming out of gcc in 3rd party code I do not wish to edit?
- error: use of deleted function
- GNU C++ how to check when -std=c++0x is in effect?
- SetJmp/LongJmp: Why is this throwing a segfault?
- GCC: Difference between -O3 and -Os
- Does the restrict keyword provide significant benefits in gcc/g++?
- Difference between regex_match and regex_search?
- Why does sqrt() work fine on an int variable if it is not defined for an int?
- Why should I initialize member variables in the order they’re declared in?
- Understanding -Weffc++
- Undocumented GCC Extension: VLA in struct
- How should I use g++’s -finput-charset compiler option correctly in order to compile a non-UTF-8 source file?
- List of common C++ Optimization Techniques [closed]