473,326 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Warning missing?

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

Nov 14 '05 #1
7 1673

sergio.borgh...@gmail.com wrote:
Hello,

Why this code compile without any warning?

What warning did you expect?


Brian

Nov 14 '05 #2
se*************@gmail.com 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) ks***@mib.org <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.
Nov 14 '05 #3
se*************@gmail.com 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"
Nov 14 '05 #4

Martin Ambuhl wrote:
se*************@gmail.com 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

Nov 14 '05 #5
se*************@gmail.com wrote:
Martin Ambuhl wrote:
se*************@gmail.com 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.
Nov 14 '05 #6
se*************@gmail.com 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[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\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[i]\
);}return 0;}
Nov 14 '05 #7
se*************@gmail.com 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?"

Nov 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Šimon Tóth | last post by:
Can anybody tell me how to turn of this warning? -Wno-deprecated doesn't work. I don't want to edit the source file, because it works fine and it's a bit hardcore stuff for me :) warning:...
4
by: Bill Dee | last post by:
I use XML comments around most of my class libraries public property and methods, for example: /// <summary> /// blah blah /// </summary> However I have a few dozen public constants as well...
4
by: Ced | last post by:
Hi, i'm not an expert in C but i try to compile BTNG software under linux kernel 2.4.2-2. I get these errors at the very first stage. Does someone could have a rapid look on this and tell me...
1
by: spanov | last post by:
i've got problem installing python-2.3.5 from sources on FreeBSD 5.3 root@server# ./configure > conf_log configure: WARNING: curses.h: present but cannot be compiled configure: WARNING:...
6
by: Daniel Rudy | last post by:
Hello Group. Please consider the following code: /* this table is used in the wipedevice routine */ static const struct wipe_t { uchar wte; /* wipe table entry */ } wipetable = {...
2
by: KMEscherich | last post by:
Using Access '97 Hi there, am wondering how I can incorporate the code for a CLOSE button and also a warning that some fields are missing data. I have the following, but it seems to be wrong. ...
92
by: Heinrich Pumpernickel | last post by:
what does this warning mean ? #include <stdio.h> int main() { long l = 100; printf("l is %li\n", l * 10L);
11
by: Jeff | last post by:
I turned on errors in php: ini_set('display_errors','1'); And I got a slew of notices and a couple of warnings. The notices are mostly missing indexes from doing things like this: ...
9
by: dissectcode | last post by:
I couldn't find an anser on google...The following code is a tiny made-up example showing the problem I am looking at, at work. I have a struct: struct door_t { BOOL color; BOOL size; ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.