Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 02-05-2006, 12:46 AM   #1
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

Old 02-05-2006, 01:10 AM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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
LQ 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:


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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:36 AM.

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