|
From: <par...@ya...> - 2002-11-19 11:47:27
|
Can Anyone tell me why this code WORKS FINE in DevC++?
ANSI C says that it any Ansi compiler should give you an error (see K&R
book).
Thank you very much!
Paul
-----------------------------------------------------------
main ()
{
printf("hello, world
\n
");
system("PAUSE");
}
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
|
|
From: Arnvid K. <ar...@ka...> - 2002-11-19 12:36:40
|
On Tue, 19 Nov 2002 11:47:21 +0000 (GMT) - Paul Ardeleanu <par...@ya...> wrote:
> Can Anyone tell me why this code WORKS FINE in DevC++?
> ANSI C says that it any Ansi compiler should give you an error (see K&R
> book).
> Thank you very much!
> Paul
>
> -----------------------------------------------------------
> main ()
> {
> printf("hello, world
> \n
>
>
> ");
> system("PAUSE");
> }
A good thing in c is always to do a
return 0;
before the last } in main... gcc and many other compilers complain if
you don't. so keep the compilers happy ;)
|
|
From: Brenden T. <br...@rc...> - 2002-11-19 18:37:13
|
Newlines are illegal in string constants, according to K&R. It's a bug,
you should reported to the DevCpp folks.
Paul Ardeleanu wrote:
>Can Anyone tell me why this code WORKS FINE in DevC++?
>ANSI C says that it any Ansi compiler should give you an error (see K&R
>book).
>Thank you very much!
>Paul
>
>-----------------------------------------------------------
>main ()
>{
> printf("hello, world
> \n
>
>
> ");
> system("PAUSE");
>}
>
>__________________________________________________
>Do You Yahoo!?
>Everything you'll ever need on one web page
>from News and Sport to Email and Music Charts
>http://uk.my.yahoo.com
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by: To learn the basics of securing
>your web site with SSL, click here to get a FREE TRIAL of a Thawte
>Server Certificate: http://www.gothawte.com/rd524.html
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
>
>
|
|
From: <or...@vp...> - 2002-11-19 21:15:52
|
Hi problem hunters! Tuesday, November 19, 2002, 7:37:32 PM, Brenden wrote: BT> Newlines are illegal in string constants, according to K&R. It's a bug, BT> you should reported to the DevCpp folks. Well, first of all the compiler has nothing to do with the DevCpp developers. The compiler that DevCpp uses, is the Minimalist GNU for Windows (MinGW). It uses the GNU Compiler Collection (gcc) for compiling. Take a look at http://www.mingw.org for details. >>main () >>{ >> printf("hello, world >> \n >> >> >> "); >> system("PAUSE"); >>} The reason why this works, is this: " Using the GNU Compiler Collection: String Literals with Embedded Newlines As an extension, GNU CPP permits string literals to cross multiple lines without escaping the embedded newlines. Each embedded newline is replaced with a single `\n' character in the resulting string literal, regardless of what form the newline took originally. CPP currently allows such strings in directives as well (other than the `#include' family). This is deprecated and will eventually be removed. " As you could read, it is DEPRECATED. GCC 3.2 (what I have installed) gives the following warning for the program (older ones don't): warning: multi-line string literals are deprecated Look at: http://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/ and search for "String Literals with Embedded Newlines". -- Best regards, Oroszi Balázs mailto:or...@vp... PGP-FP: FB80 8A43 2664 6126 E465 46E2 2546 CFA3 C25B 9F70 finger -l or...@se... |
|
From: Brenden T. <br...@rc...> - 2002-11-20 00:53:00
|
Oroszi Balázs wrote: >Well, first of all the compiler has nothing to do with the DevCpp >developers. > Duoh! I keep forgetin' that. >As you could read, it is DEPRECATED. GCC 3.2 > Good, so the GCC guys know about it, and it's being worked on. Problem solved, I'd say. TTFN! |
|
From: Ioannis V. <no...@ho...> - 2002-11-19 20:20:54
|
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...] On Behalf
> Of Paul Ardeleanu
> Sent: Tuesday, November 19, 2002 1:47 PM
> To: dev...@li...
> Subject: [Dev-C++] A simple problem
>
>
> Can Anyone tell me why this code WORKS FINE in DevC++?
> ANSI C says that it any Ansi compiler should give you an
> error (see K&R
> book).
> Thank you very much!
> Paul
>
> -----------------------------------------------------------
> main ()
> {
> printf("hello, world
> \n
>
>
> ");
> system("PAUSE");
> }
It is valid C90 code (and not C99).
The main() thing is implicit int. In C90 you could do:
const x=7;
and it was equivallent to const int x=7;
main() was equivallent to int main(). This is not the case in C99.
Now both in C90 and C99 if you do not declare a function and you use it,
a declaration of the type
int whatever_you_use(); is assumed. The empty parenthesis is not
equivallent to (void) as in C++. Empty parenthesis means that you want
to skip argument checking.
So when you use printf() without <stdio.h>, int printf(); is assumed.
Ioannis Vranos
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL: http://run.to/noicys
|
|
From: <par...@ya...> - 2002-11-19 20:31:26
|
Ioannis,
I was talking about printf on multiple lines. Kala? :)
Paul
--- Ioannis Vranos <no...@ho...> wrote: > > -----Original
Message-----
> > From: dev...@li...
> > [mailto:dev...@li...] On Behalf
> > Of Paul Ardeleanu
> > Sent: Tuesday, November 19, 2002 1:47 PM
> > To: dev...@li...
> > Subject: [Dev-C++] A simple problem
> >
> >
> > Can Anyone tell me why this code WORKS FINE in DevC++?
> > ANSI C says that it any Ansi compiler should give you an
> > error (see K&R
> > book).
> > Thank you very much!
> > Paul
> >
> > -----------------------------------------------------------
> > main ()
> > {
> > printf("hello, world
> > \n
> >
> >
> > ");
> > system("PAUSE");
> > }
>
>
> It is valid C90 code (and not C99).
>
> The main() thing is implicit int. In C90 you could do:
>
>
> const x=7;
>
> and it was equivallent to const int x=7;
>
>
> main() was equivallent to int main(). This is not the case in C99.
>
>
> Now both in C90 and C99 if you do not declare a function and you use it,
> a declaration of the type
>
>
> int whatever_you_use(); is assumed. The empty parenthesis is not
> equivallent to (void) as in C++. Empty parenthesis means that you want
> to skip argument checking.
>
>
> So when you use printf() without <stdio.h>, int printf(); is assumed.
>
>
> Ioannis Vranos
>
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL: http://run.to/noicys
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: To learn the basics of securing
> your web site with SSL, click here to get a FREE TRIAL of a Thawte
> Server Certificate: http://www.gothawte.com/rd524.html
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
|
|
From: Luigi S. <gi...@li...> - 2002-11-20 17:58:21
|
On Tue, Nov 19, 2002 at 11:47:21AM +0000, Paul Ardeleanu wrote:
> Can Anyone tell me why this code WORKS FINE in DevC++?
> ...
> -----------------------------------------------------------
> main ()
> {
> printf("hello, world
> \n
>
>
> ");
> ...
Try adding the options "-ansi -pedantic" and you'll see that
the compiler complains about strings extending past the end
of a line.
If you replace "-pedantic" by "-pedantic-errors", the compiler
will refuse to generate object file.
--
>> gisan >>
Q: Why did Menachem Begin invade Lebanon?
A: To impress Jodie Foster.
|
|
From: <par...@ya...> - 2002-11-21 18:38:32
|
Is there any place where all these options are explain? Thanks! Paul --- Luigi Santillo <gi...@li...> wrote: > Try adding the options "-ansi -pedantic" and you'll see that > the compiler complains about strings extending past the end > of a line. > > If you replace "-pedantic" by "-pedantic-errors", the compiler > will refuse to generate object file. __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com |
|
From: Ioannis V. <no...@ho...> - 2002-11-21 20:16:21
|
> -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf > Of Paul Ardeleanu > Sent: Thursday, November 21, 2002 8:38 PM > To: dev...@li... > Subject: Re: [Dev-C++] A simple problem > > > Is there any place where all these options are explain? > Thanks! http://gcc.gnu.org at the documentation area. Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL: http://run.to/noicys |