Since C++17 you can use the [[nodiscard]]
attribute.
Example:
[[nodiscard]] int bar() {
return 42;
}
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?
- Undefined reference to vtable
- 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]
- How to turn on (literally) ALL of GCC’s warnings?
- 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?
- How to create a static library with g++?
- How to force gcc to link an unused static library
- What is the purpose of using -pedantic in the GCC/G++ compiler?
- gcc/g++: “No such file or directory”
- 😃 (and other Unicode characters) in identifiers not allowed by g++
- Compiling multithread code with g++
- How can I turn on (literally) ALL of GCC’s warnings?
- constexpr initializing static member using static function
- How to tell where a header file is included from?
- How to include omp.h in OS X?
- error: use of deleted function
- Linking g++ 4.8 to libstdc++
- What’s the point of g++ -Wreorder?
- Update GCC on OSX
- Linking to MSVC DLL from MinGW
- GCC: Difference between -O3 and -Os
- GNU C++ how to check when -std=c++0x is in effect?
- SetJmp/LongJmp: Why is this throwing a segfault?
- Does the restrict keyword provide significant benefits in gcc/g++?
- How to use multiple versions of GCC
- How to automatically generate a stacktrace when my program crashes
- How do you get assembler output from C/C++ source in gcc?
- trap representation
- Why vector::reference doesn’t return reference to bool?
- /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15′ not found
- __builtin_prefetch, How much does it read?
- Does MinGW-w64 support std::thread out of the box when using the Win32 threading model?
- Static Data Member Initialization
- std::stoi doesn’t exist in g++ 4.6.1 on MinGW
- Declaring the array size with a non-constant variable
- How do I call “cpuid” in Linux?
- Linking libstdc++ statically: any gotchas?
- GCC, stringification, and inline GLSL?
- inlining failed in call to always_inline ‘__m256d _mm256_broadcast_sd(const double*)’
- Compile a DLL in C/C++, then call it from another program
- Is there a compiler bug exposed by my implementation of an is_complete type trait?
- Why does GCC generate 15-20% faster code if I optimize for size instead of speed?
- When including header files, is the path case sensitive?
- When will Gnu C++ support C++11 without explicitly asking for it?
- Difference between CC, gcc and g++?