#pragma warn example in C



For disabling warnings (non-critical Messages ) we can use #pragma warn directive


Syntax:

#pragma warn +xxx
#pragma warn -xxx
#pragma warn .xxx

+ -----> means on
- -----> means off
. ------> means toggle

xxx is  a 3 character warning code. For example rvl means ignore all the warnings where there is function which has to  return value but is not returning.

Code:


#include<stdio.h>

#pragma warn rvl
int add(int a,int b);
int main()
{

add(3,5);

}


int add(int a,int b){


printf("The result is %d",a+b);
}



This will not be supported by gcc  compiler as it does not support all the #pragma directives . First if we compile this program with gcc ,the compiler will not show any warnings. To see the warnings we have to pass -Wall arguments to the gcc compiler. 

Comments

Popular posts from this blog

bb.utils.contains yocto

Difference between RDEPENDS and DEPENDS in Yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig