LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   why does gcc gives warning not an error..?? (https://www.linuxquestions.org/questions/programming-9/why-does-gcc-gives-warning-not-an-error-411787/)

arunka 02-05-2006 12:46 AM

why does gcc gives warning not an error..??
 
hi all
i wrote a C program which basically tries to modify a const variable.
when i compliled it gave onle warninnig..?
why it is like this?
Is it compiler dependendent or behaviour is undefined in C standards..

Thanks in advance

Arun

btmiller 02-05-2006 01:10 AM

Gcc will sometimes let you get away with stuff you really should not be doing. There are flags you can set that determine how many warnings it will give you. I'd start with -W and -Wall, but there are others if you read the man page. if you want all warnings to be treated as errors, use -Werror. FWIW, you really should nopt leave any warnings in programs.

paulsm4 02-05-2006 01:15 AM

If you use "-ansi" and "-pedantic" switches, you'll see the behavior you expect.

These links might give you a bit more detail about what's going on:

http://www.mit.edu/afs/athena/astaff.../c/c_compilers
http://gcc.gnu.org/onlinedocs/gcc-4....#toc_Standards


All times are GMT -5. The time now is 04:09 PM.