Warning missing?

  • Thread starter sergio.borghese
  • Start date
S

sergio.borghese

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
 
K

Keith Thompson

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>
 
M

Martin Ambuhl

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"
 
S

sergio.borghese

Martin said:
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
 
M

Martin Ambuhl

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.
 
B

Ben Pfaff

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.
 
E

Emmanuel Delahaye

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?"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top