- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am looking for a way to suppress warning #177: "variable was declared but never referenced" for certain variables throughout my code. The GCC compiler has __attribute__((unused)) for this.
According to the documentation Composer XE 12.1 should allow me to use "#pragma unused". However, using this approach the compiler issues the warning: "warning #161: unrecognized #pragma unused".
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does attribute unused not work with our compiler? If so can you provide an example and tell us which version of the compiler you are using?
I tried a simpleexample with version 12.1 and it seems towork for me:
sptxl8-446> cat att.c
#ifdef OK
static void foo() __attribute__((unused));
#endif
static void foo()
{
#ifdef OK
int j __attribute__((unused));
#else
int j;
#endif
}
sptxl8-447> icpc -Wremarks -c att.c
att.c(13): remark #177: variable "j" was declared but never referenced
int j;
^
att.c(8): remark #177: function "foo" was declared but never referenced
static void foo()
^
sptxl8-448> icpc -Wremarks -DOK -c att.c
sptxl8-449>
thanks
Judy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use the following version together with Visual Studio 2010 on Windows 7 64bit.
c:\\Program Files (x86)\\Intel\\Composer XE 2011 SP1\\bin\\intel64\\icl
Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.3.300 Build 20120130
I've tried your simple example:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
void foo(int a, int b)
{
++a;
_UNUSED_(b)
}
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#pragma unused does also not work because of Microsoft compatiblity?
http://software.intel.com/sites/products/documentation/hpc/composerxe/en-us/2011Update/cpp/win/cref_cls/common/cppref_pragma_unused.htm#cppref_pragma_unused
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page