#pragma warn directive in c


In c there are many warning messages which can be on or off with help of #pragma warn.
Syntax :

#pragma warn +xxx
#pragma warn –xxx
#pragma warn .xxx

Where
+ means on
- means off
. means on/off (toggle)


xxx is indicate particular warning code in thee alphabet. Example :
rvl is warning code which means function should return a value.

#include<stdio.h>
#pragma warn –rvl
int main(){
    printf("It will not show any warning message");
    return 0;
}


Output: It will not show any warning message

When you will execute the above program then compiler will not show the warning message function should return a value because rvl warning is off.
List of warning code :


S.N.
Warning message
Code
ANSI Violations
1
Assigning 'type' to 'enumeration'
eas
2
Bit fields must be signed or unsigned int
bbf
3
Both return and return with a value used
ret
4
Declare type 'type' prior to use in prototype
dpu
5
Division by zero
zdi
6
Hexadecimal value contains more than 3 digits
big
7
Initializing 'enumeration' with 'type'
bei
8
'identifier' is declared as both external and static
ext
9
Ill-formed pragma
ill
10
Initialization is only partially bracketed
pin
11
Redefinition of 'macro' is not identical
dup
12
Suspicious pointer conversion
sus
13
Undefined structure 'structure'
stu
14
Void functions may not return a value
voi
Frequent Errors
1
Code has no effect
eff
2
Function should return a value
rvl
3
Parameter 'parameter' is never used
par
4
Possible use of 'identifier' before definition
def
5
Possibly incorrect assignment
pia
6
Unreachable code
rch
Less Frequent Errors
1
Ambiguous operators need parentheses
amb
2
Array variable 'identifier' is near
ias
3
Call to function with no prototype
pro
4
Call to function 'function' with no prototype
pro
5
Condition is always false
wccc
6
Condition is always true
wccc
7
'identifier' declared but never used
use
8
'identifier' is assigned a value that is never used
aus
9
No declaration for function 'function'
nod
10
Structure passed by value
stv
11
Superfluous & with function
amp
Portability Warnings
1
Constant is long
cln
2
Constant out of range in comparison
rng
3
Conversion may lose significant digits
sig
4
Non portable pointer comparison
cpt
5
Non portable pointer conversion
rpt
6
Mixing pointers to signed and unsigned char
ucp


  • Preprocessor definitions in c
  • Preprocessor directive in c
  • #include directive in c
  • # define directive in c
  • Pragma directive in c
  • Warning directive
  • Preprocessor operators in c
  • # if directive in c
  • #line directive in c
  • # error directive in c
  • # elif in c
  • # ifdef and #endif in c
  •  # ifndef in c example
  • #undef in c
  • What is header file in ?
  • C preprocessor questions
  • C tutorial home.
  • 1 comment:

    Anonymous said...

    Short and simple but very informative articles on C. It helps me to enhance my knowledge!! I have added this to my Google reader and expecting many more!


    Banking Job Descriptions