This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

__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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]