Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

GCC 4.4.4 C99 EXTREME WARNING MODE

Name: Anonymous 2010-08-29 6:05

I want to compile a C99 program in GCC 4.4.4 but I want to do it in EXTREME WARNING MODE.

How do I do that?

Name: Anonymous 2010-08-29 6:06

Bang your head into a -Wall.

Name: Anonymous 2010-08-29 6:08

-Wall -Wextra -Werror -pedantic -strict -ansi -std=c89

Name: Anonymous 2010-08-29 6:08

>>3
-std=c99

Name: Anonymous 2010-08-29 6:10

>>3
there be mo W's in that list,bauss

Name: Anonymous 2010-08-29 6:37

-O2 -std=c99 -Werror -pedantic -Wall -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wsync-nand -Wunknown-pragmas -Wstrict-overflow=5 -Wsuggest-attribute=pure -Wsuggest-attribute=const  -Wsuggest-attribute=noreturn -Wsystem-headers -Wtrampolines -Wtraditional -Wfloat-equal -Wtraditional-conversion -Wdeclaration-after-statement -Wundef -Wshadow -Wunsafe-loop-optimizations -Wpointer-arith -Wbad-function-cast -Wc++-compat -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-format-attribute -Wnormalized=nfkc -Wpacked -Wpadded -Wredundant-decls -Wnested-externs  -Winline -Winvalid-pch -Wlong-long -Wvla -Wdisabled-optimization -Wstack-protector -Wunsuffixed-float-constants

Name: Anonymous 2010-08-29 7:10

>>1
$ info gcc, ``faggot''

Name: Anonymous 2010-08-29 10:57

>>3
-ansi and -std=c89 are the same thing.

Name: sage 2010-08-29 12:30

>>6
>-Os

FTFY

Name: Anonymous 2010-08-29 13:44

>>8
Why? The current ANSI standard is C99.

Name: Anonymous 2010-08-29 16:09

>>10
The non-ANSI standard ANSI is C89.

Name: Anonymous 2010-08-29 22:57

>>10
That's ISO.

Name: Anonymous 2010-08-30 2:14

>>12
>In March 2000, ANSI adopted the ISO/IEC 9899:1999 standard. This standard is commonly referred to as C99, and it is the current standard for C programming language.

IIRC the reason gcc defaults to C89 for -ansi is because they don't support all of C99, but I'm too lazy to confirm that.

Name: Anonymous 2010-08-30 7:50

>>13
It's because "ANSI C" means C89 in practice.

Name: Anonymous 2010-08-30 7:59

>>13
gcc -std=C99
most other compilers, though, do not implement C99. sadly C1x will come before we see every compiler conforming to C99.

Name: Anonymous 2010-08-30 9:14

>>15
That's weird. All the hardcore C++ programmers out their can't take the efficiency of their language and whip out an optimizing compiler? I mean, these guys understand everything about computers, abstraction, and getting down to the metal.

Name: Anonymous 2010-08-30 10:02

>>13
The actual reason gcc's -ansi is C89 instead of C99 is because that switch is older than C99, and changing its behavior breaks backward compatibility.

Name: Anonymous 2010-08-30 11:06

>>17
No, sorry, you're incorrect. Please don't make shit up.

By default, GCC provides some extensions to the C language that on rare occasions conflict with the C standard. See Extensions to the C Language Family. Use of the -std options listed above will disable these extensions where they conflict with the C standard version selected. You may also select an extended version of the C language explicitly with -std=gnu90 (for C90 with GNU extensions), -std=gnu99 (for C99 with GNU extensions) or -std=gnu1x (for C1X with GNU extensions). The default, if no C language dialect options are given, is -std=gnu90; this will change to -std=gnu99 in some future release when the C99 support is complete. Some features that are part of the C99 standard are accepted as extensions in C90 mode.
http://gcc.gnu.org/onlinedocs/gcc/Standards.html

Name: Anonymous 2010-08-30 14:49

>>18
Did you just paste a random passage in the hope that nobody would read it and realise you're full of shit? There's nothing there that has anything to do with >>17-kun's post.

Name: Anonymous 2010-08-30 15:51

Behold, my aclocal file (just put ENABLE_WARNINGS in configure.in and configure with --enable-warnings, or --enable-warnings=-Werror or whatever).  If you're not using autotools, then you're PROBABLY using something inferior.  Autotools sucks really hard, but still manages to suck less than SCons, Jam, CMake, or your favorite IDE.


AC_DEFUN([ENABLE_WARNINGS],[
  AC_ARG_ENABLE(warnings,
    [  --enable-warnings       enable warnings for GCC ],
    [enable_warnings=$enableval], [warnings=no])
  if test "x$enable_warnings" != xno ; then
    [warning_cflags="-Wall -Wextra -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wchar-subscripts -Wredundant-decls -pedantic"]
    if test "x$enable_warnings" != xyes ; then
      [warning_cflags="$warning_cflags $enable_warnings"]
    fi
  fi
  AC_SUBST([warning_cflags])
])


The "-Wshadow" can be a bitch, I have to rename variables e.g. "index" because there is a standard library function named "index".

I used to use "-Wno-unused-parameter" but I turned it on and it caught some bugs so I leave it on now, and stick these in my code:


int always_returns_three(int x)
{
    (void)x;
    return 3;
}


It's ugly but my code DOES have less bugs now.

As an alternative, plug in "clang" for a bit.  It might spit out a bunch of new warnings, they'll often be pretty nice.

Name: Anonymous 2010-08-30 15:57

>>20
As a quick addendum, don't put "-W" options in CFLAGS, put them in a separate variable and then add that variable to AM_CFLAGS in Makefile.am.  If you put them in CFLAGS, your configuration script might break, or fail to detect certain libraries that are installed.

Name: Anonymous 2010-08-30 20:50

>>20
Yeah, the problem with things like SCons and CMake is that the developers of these tools never really have experienced the need to have full control over the build process. They're lazy developers who don't care about actual REAL WORLD use cases.

Name: Anonymous 2010-08-30 21:26

>>22
You don't have full control over the build process until you've written your makefiles and configure script by hand.

Which I do. (autotools sucks that much)

Name: Anonymous 2010-08-30 21:29

The most hilarious thing about all these shitty build systems is that the whole point of make was to stop using shell scripts to build things.

Name: Anonymous 2010-08-30 22:14

>>24
Thanfully, someone realized that we need scripts to build makefiles to build things.

Name: Anonymous 2010-08-31 0:04

>>19
YHBT
>>20-25
YHNBT

Name: Anonymous 2010-08-31 0:42

>>26
HIBT?

Name: Anonymous 2010-08-31 11:26

>>27
YMHBT

Name: Anonymous 2010-12-09 14:19

Name: Anonymous 2013-09-01 10:08



   _,.へ、_ _,....,_,./^L
   ) ___ ゝ'-─'─- 、i、
  く  γ´:::::::::::::::::::::::::::ヽ!
  iヽ,'::,'::::::/::::::::ハ::::i-=iニ',    
  |::::L!::::L!:ゝ、イ レi,.イハ::」    ∧ ☆
  .|::::|ヘ(Eイ〈ヒ_,!  ヒ,}〉iヨイ   /  ',
  .|::::|::レヽ!、"   ∀ "ノ.i::|   / r´i
  .|::::|::::|::|Vi >r-r=i´レiノ   / r' /
  |::||:::::γヽ!_ `'ハイiヽv__  ,〈 ,r'´/
  レヘハ,〈γ(・ヽ, ム !/^ /rつi>、/
     k.iゝ・)ノ_____,」、__ゝ(_ノ
      /  ̄7 ̄`! ヘ
    ,く / /   ! .ハ   
     ヽニr=-r_,r-=rニゝ  
       '--'  '--'

Don't change these.
Name: Email:
Entire Thread Thread List