#pragma warn Macro Directive in C | Suppress Warning Messages



Topics : How to Suppress Warning Messages in C ?

  1. What is Warning Message in C ?
  2. What is Error and Message in C ?
  3. #pragma warn Directive in C
  4. Live Example
  5. List of Warning Codes in ANSI

Warning Message :

  • A warning is a non-critical condition that does not require immediate attention.
  • Warning can be ignored.
  • Waring will never stop your execution of C Program.

Error Message

  • An Error is a critical condition that requires immediate attention.
  • Error messages cannot be ignored.
  • Compile Error won’t let you to run C Program.
  • run Time Error will terminate current execution of C program

#pragma warn Macro Directive in C

  1. 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)
  1. xxx is indicate particular warning code in thee alphabet.
  2. Example : rvl warning code means function should return a value.

Live Example :

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

Explanation :

  1. -rvl mean suppress warning message .
  2. rvl means : “Function should return a value“.
  3. We have specified return type of main as “Integer” but we are not going to return a value.
  4. Usually this program will show warning message.
  5. We have suppressed warning already (-rvl) so we won’t get any warning message.
  6. Standard notation and there actual meaning is shown inside following table -

List of Warning Codes in C

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