Mail Archives: djgpp/1997/09/18/18:02:23
From: | "M. Schulter" <mschulter AT value DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: DJGPP makes big .exe's
|
Date: | 17 Sep 1997 06:02:36 GMT
|
Organization: | Value Net Internetwork Services Inc.
|
Lines: | 60
|
Message-ID: | <5vnrps$2ps$2@vnetnews.value.net>
|
References: | <5vn586$86e$1 AT news DOT wco DOT com>
|
NNTP-Posting-Host: | value.net
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
`Lord_RaT~ <avenger3 AT hotmail DOT com> wrote:
: void main()
: {
: printf("This is my generic programme\n");
: printf("This is fun/n");
: }
Hi, there.
As someone just starting to learn assembler, and hardly an expert in C
<grin>, I may hardly be an authority on programming style. However, may I
suggest a couple of points that might be helpful either in DJGPP or in
other environments?
Here's a revised version of your code, with three main changes:
#include <stdio.h>
int main(void)
{
printf("This is my generic programme\n");
printf("This is fun\n");
return(0);
}
(1) You should include the standard i/o library, stdio.h, which provides
functions including printf(). This assumes, of course, that you quoted
your complete program, and didn't have the #include in an unquoted
portion.
(2) While some books break this rule, main() must _always_ return an
integer, which informs the operating system of your program's exit
condition. Thus you should use 'int main(void)', and _not_ any form with
'void main'
(3) By the same rule, you should always have main() return a value, 0 for
a normal exit, as in this revision.
Please note that if you compile with gcc using the -Wall option, you'll
get warnings on issues of this kind; I've found it a great help in my own
programming.
BTW, GCC is my first compiler, and I hope the above is helpful.
Maybe I should explain something about the culture of this group: those of
us who have been here for even a few months have seen _lots_ of posts
which seem to treat a "hello, world" program as the ultimate benchmark for
a 32-bit compiler <grin>.
Actually, I would say that gcc and Emacs provides a great platform for
programs of any size, and would encourage you to keep on learning.
Most respectfully,
Margo Schulter
mschulter AT value DOT net
(To reply, please remove the extra . from my default address)
- Raw text -