This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
__attribute__((warn_unused_result)
- From: "Mohanlal Jangir" <mohanlaljangir at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 6 Apr 2007 22:38:54 +0900
- Subject: __attribute__((warn_unused_result)
I tried to use warn_unused_result in following C++ code.
#include <stdio.h>
class myClass {
public:
int count() __attribute__((warn_unused_result))
{
return printf("hello world\n");
}
};
int main() {
myClass obj;
obj.count();
return 0;
}
But it is giving compile error.
test.cpp:6: syntax error before `{' token
Could someone tell me how to use this attribute in C++ methods?
bash-2.05b$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-20)
Regards,
Mohan