Community
cancel
Showing results for 
Search instead for 
Did you mean: 
inteluser
Beginner
209 Views

pragma unused

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".

0 Kudos
5 Replies
Judith_W_Intel
Employee
209 Views


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
inteluser
Beginner
209 Views

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:

3> main.cpp
3>main.cpp(5): error : expected a "{"
3> static void foo() __attribute__((unused));
3> ^
3>
3>main.cpp(8): warning #12: parsing restarts here after previous syntax error
3> {
3> ^
3>
3>main.cpp(9): error : expected a ";"
3> int j __attribute__((unused));
3> ^
TimP
Black Belt
209 Views

Unfortunately, gcc extensions such as __attribute__ don't work with the Microsoft-compatible Windows compiler. You may find the mingw 64-bit gcc compiler useful.
jimdempseyatthecove
Black Belt
209 Views

#define _UNUSED_(x) (void)x;
void foo(int a, int b)
{
++a;
_UNUSED_(b)
}

Jim Dempsey
inteluser
Beginner
209 Views

#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_...
Reply