- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do I get Intel 16 to generate warnings if I mix enum types.
# Begin
c:\Users\eda\mosekdbg>icl testenum.c
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 16.0.2.180 Build 20160204
Copyright (C) 1985-2016 Intel Corporation. All rights reserved.
testenum.c
Microsoft (R) Incremental Linker Version 11.00.50727.1
Copyright (C) Microsoft Corporation. All rights reserved.
-out:testenum.exe
testenum.obj
# End
clang says
eda@karise:~/mosekprj/dev$ clang-3.6 ~/testenum.c -o testenum
/home/eda/testenum.c:27:11: warning: implicit conversion from enumeration type 'anotherenum' to different enumeration type
'someenum' [-Wenum-conversion]
myfunc(mid);
~~~~~~ ^~~
1 warning generated.
eda@karise:~/mosekprj/dev$
And that is what I want. Can Intel C do that?
Here is the code I compile.
#include <stdio.h>
typedef enum
{
lower = 0,
upper = 1
} someenum;
typedef enum
{
mid = 8
} anotherenum;
void myfunc(someenum e)
{
printf("enum test %d\n",(int) e);
if ( e>=lower )
printf("e>=lower\n");
else
printf("e<lower\n");
}
int main()
{
myfunc(mid);
}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can see the warning like this:
icc -c fu.c -diag-warning:188
fu.c(28): warning #188: enumerated type mixed with another type
myfunc(mid);
I'll create a bug report about the missing Warning option:
-bash-4.2$ icc -c fu.c -Wenum-conversion
icc: command line warning #10006: ignoring unknown option '-Wenum-conversion'
The way I found the error number was to run the compiler with the -w3 option which prints all the available warnings and remarks. Then i used the "-diag-warning:188" option to print 188 as a warning
icc -c fu.c -w3
fu.c(17): remark #1418: external function definition with no prior declaration
void myfunc(someenum e)
^
fu.c(28): warning #188: enumerated type mixed with another type
myfunc(mid);
^
fu.c(29): remark #1011: missing return statement at end of non-void function "main"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On Windows it is /Qdiag-warning:188.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Melanie, as always.
@erling_andersen: Yes, it's /Qdiag-warning:188 on windows.
Kittur

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page