__attribute__((warn_unused_result)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux