LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-05-2006, 12:46 AM   #1
arunka
Member
 
Registered: Mar 2005
Posts: 60

Rep: Reputation: 15
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
 
Old 02-05-2006, 01:10 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,128

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
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.
 
Old 02-05-2006, 01:15 AM   #3
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc 4.0.0 warning: dereferencing type-punned pointer will break strict-aliasing rules stephenwalter Programming 4 06-10-2009 04:06 AM
Implicit typename warning (gcc 3.3.4) ta0kira Programming 1 10-12-2004 03:45 AM
gcc warning compiling C code vose Programming 2 09-29-2004 10:58 AM
Warning error at boot... Russb Linux - General 1 08-10-2004 10:58 AM
lilo error: Well, more of a Warning vexer Slackware 8 07-26-2003 11:38 AM


All times are GMT -5. The time now is 05:43 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration