Warning missing?

Discussion in 'C Programming' started by sergio.borghese@gmail.com, Apr 7, 2005.

  1. Guest

    Hello,

    Why this code compile without any warning?
    I compile it on gcc 3.3.4 with the following command:

    gcc -Wall -pedantic -ansi test.c

    #include <stdlib.h>
    #include <stdio.h>

    int pippo(inx)
    {
    return inx/2;
    }

    int main(void)
    {
    int i = 6;
    char c = 12;

    printf("%d", pippo(i));
    printf("%d", pippo(c));
    return 0;
    }

    Thank to all.

    Sergio
     
    , Apr 7, 2005
    #1
    1. Advertising

  2. Default User Guest

    wrote:
    > Hello,
    >
    > Why this code compile without any warning?



    What warning did you expect?




    Brian
     
    Default User, Apr 7, 2005
    #2
    1. Advertising

  3. writes:
    > Why this code compile without any warning?
    > I compile it on gcc 3.3.4 with the following command:
    >
    > gcc -Wall -pedantic -ansi test.c
    >
    > #include <stdlib.h>
    > #include <stdio.h>
    >
    > int pippo(inx)
    > {
    > return inx/2;
    > }
    >
    > int main(void)
    > {
    > int i = 6;
    > char c = 12;
    >
    > printf("%d", pippo(i));
    > printf("%d", pippo(c));
    > return 0;
    > }


    What warning were you expecting?

    <OT>"-W -Wall" enables more warnings than "-W" alone.</OT>

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Apr 7, 2005
    #3
  4. wrote:
    > Hello,
    >
    > Why this code compile without any warning?


    I don't know why your version of gcc compiles without warning. _My_
    copy gives this warning:
    a.c:5: warning: type of "inx" defaults to "int"
     
    Martin Ambuhl, Apr 7, 2005
    #4
  5. Guest

    Martin Ambuhl wrote:
    > wrote:
    > > Hello,
    > >
    > > Why this code compile without any warning?

    >
    > I don't know why your version of gcc compiles without warning. _My_
    > copy gives this warning:
    > a.c:5: warning: type of "inx" defaults to "int"


    I would expect a warning like that: in my sample code the argument type
    is missing in the function.

    Which gcc version you have?

    Thanks,

    Sergio
     
    , Apr 7, 2005
    #5
  6. wrote:
    > Martin Ambuhl wrote:
    >
    >> wrote:
    >>
    >>>Hello,
    >>>
    >>>Why this code compile without any warning?

    >>
    >>I don't know why your version of gcc compiles without warning. _My_
    >>copy gives this warning:
    >>a.c:5: warning: type of "inx" defaults to "int"

    >
    >
    > I would expect a warning like that: in my sample code the argument type
    > is missing in the function.
    >
    > Which gcc version you have?


    This belong in a gcc or gnu newsgroup. My version is 3.4.3. Please
    direct any further questions to an appropriate newsgroup.
     
    Martin Ambuhl, Apr 7, 2005
    #6
  7. Ben Pfaff Guest

    writes:

    > I would expect a warning like that: in my sample code the argument type
    > is missing in the function.


    Your code looked like this:
    int foo(bar)
    {
    ...
    }
    This is a valid non-prototype style function definition. It
    could be written more explicitly like this:
    int foo(bar)
    int bar;
    {
    ...
    }
    If you want a warning about the absence of a prototype, GCC has
    an option for that.
    --
    int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
    \n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
    );while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p\
    );}return 0;}
     
    Ben Pfaff, Apr 8, 2005
    #7
  8. wrote on 08/04/05 :
    > Hello,
    >
    > Why this code compile without any warning?
    > I compile it on gcc 3.3.4 with the following command:
    >
    > gcc -Wall -pedantic -ansi test.c


    Well, I must have a different tuning :

    main.c:9: warning: function declaration isn't a prototype
    main.c: In function `pippo':
    main.c:9: warning: type of `inx' defaults to `int'

    gcc.exe -c main.c -o dexe/main.o -W -Wall -O2 -Wshadow -Wpointer-arith
    -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion
    -Waggregate-return -Wstrict-prototypes -Wredundant-decls
    -Wnested-externs -Winline

    > #include <stdlib.h>
    > #include <stdio.h>
    >
    > int pippo(inx)
    > {
    > return inx/2;
    > }
    >
    > int main(void)
    > {
    > int i = 6;
    > char c = 12;
    >
    > printf("%d", pippo(i));
    > printf("%d", pippo(c));
    > return 0;
    > }


    --
    Emmanuel
    The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
    The C-library: http://www.dinkumware.com/refxc.html

    I once asked an expert COBOL programmer, how to
    declare local variables in COBOL, the reply was:
    "what is a local variable?"
     
    Emmanuel Delahaye, Apr 8, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pete Becker
    Replies:
    0
    Views:
    1,379
    Pete Becker
    Feb 10, 2005
  2. B. Williams

    warning C4267 and warning C4996

    B. Williams, Oct 26, 2006, in forum: C++
    Replies:
    17
    Views:
    2,635
  3. Pawel
    Replies:
    13
    Views:
    18,785
  4. WARNING! Prosoftstore.com is a SCAM! WARNING!

    , Jul 8, 2007, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    319
  5. Julian Mehnle
    Replies:
    17
    Views:
    885
    Julian Mehnle
    May 18, 2006
Loading...

Share This Page