beyond

Wshadow check

Sep 12th, 2012
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. beyond@rules->$ cat global.c
  2. #include<stdio.h>
  3. #include<stdlib.h>
  4.  
  5. int x=5;
  6.  
  7. void foo(int x,int y)
  8. {
  9. x=y;
  10. printf("%d %d\n",x,y);
  11. }
  12.  
  13. int main()
  14. {
  15. foo(2,3);
  16. return 0;
  17. }
  18. beyond@rules->$ gcc -Wall -W global.c -o global
  19. beyond@rules->$ rm global
  20. beyond@rules->$ gcc -Wshadow -Wall -W global.c -o global
  21. global.c: In function ‘foo’:
  22. global.c:6:14: warning: declaration of ‘x’ shadows a global declaration [-Wshadow]
  23. global.c:4:5: warning: shadowed declaration is here [-Wshadow]
  24. beyond@rules->$ ^C
  25. beyond@rules->$
Advertisement
Add Comment
Please, Sign In to add comment