473,396 Members | 1,666 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,396 software developers and data experts.

K&R Ex 1-3

Gio
I'm reading the K&R book and doing the exercises. Currently, I'm working
on Exercise 1-3.

Here's what I have:

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3.  
  4. main()
  5. {
  6. float fahr, celsius;
  7. float lower, upper, step;
  8.  
  9. lower = 0;   /* lower limit of temperatuire scale */
  10. upper = 300; /* upper limit */
  11. step = 20;   /* step size */
  12. fahr = lower;
  13.  
  14. printf("F\t\tC\n");
  15. while (fahr <= upper) {
  16. celsius = (5.0/9.0) * (fahr-32.0);
  17. printf("%4.0f %7.1f\n", fahr, celsius);
  18. fahr = fahr + step;
  19. }
  20. }
  21.  
  22.  
Now, this completes the exercise. Technically, anyway. However, I want
to make the "F" and "C" align properly above the right side of their
respective columns.

I realize this is probably a really minor thing, but I'd appreciate the
help none-the-less!

- Gio

--
AND NOW FOR A WORD (an IF blog):

http://giomancer.wordpress.com/
Jun 27 '08 #1
41 1523
Gio wrote:
I'm reading the K&R book and doing the exercises. Currently, I'm working
on Exercise 1-3.

Here's what I have:

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. main()
Expand|Select|Wrap|Line Numbers
  1.  
  2. make that int main(void).
  3.  
  4. While you are there, turn  your compiler's warnings up, the above should
  5. have caused one.
  6.  
  7.         
  8.                 {
  9.     float fahr, celsius;
  10.     float lower, upper, step;
  11.     lower = 0;   /* lower limit of temperatuire scale */
  12.     upper = 300; /* upper limit */
  13.     step = 20;   /* step size */
  14.     fahr = lower;
  15.     printf("F\t\tC\n");
  16.     while (fahr <= upper) {
  17.         celsius = (5.0/9.0) * (fahr-32.0);
  18.         printf("%4.0f %7.1f\n", fahr, celsius);
  19.         fahr = fahr + step;
  20.     }
  21. }
  22.  
  23.  
>
Now, this completes the exercise. Technically, anyway. However, I want
to make the "F" and "C" align properly above the right side of their
respective columns.
Just add some spaces to the first print and a couple of tabs to the second.

printf(" F\t\t C\n");
printf("%4.0f\t\t%7.1f\n", fahr, celsius);

--
Ian Collins.
Jun 27 '08 #2
Gio <gi*******@sbcglobal.netwrites:
I'm reading the K&R book and doing the exercises. Currently, I'm
working on Exercise 1-3.
<snip>
printf("F\t\tC\n");
while (fahr <= upper) {
celsius = (5.0/9.0) * (fahr-32.0);
printf("%4.0f %7.1f\n", fahr, celsius);
fahr = fahr + step;
}
<snip>
Now, this completes the exercise. Technically, anyway. However, I want
to make the "F" and "C" align properly above the right side of their
respective columns.
I like to do this using the same sizes you have in the numeric
format:

printf("%4s %7s\n", "F", "C");

It keeps everything clear, and you can even wire in a configurable size
from a macro if you really want to (although that is a serious case of
overkill in this exercise).

--
Ben.
Jun 27 '08 #3
Gio
While you are there, turn your compiler's warnings up, the above
should have caused one.
Well.. ah.. I'm working on an Apple II; the compiler I ran this program
on is technically pre-ANSI, but I've kept the differences in mind (and
the documentation close at hand). I figured I could ask a K&R question,
though.

As to why I'm learning C on an Apple IIe.. I'm doing it to get used to
the compiler and the limitations of the computer. And because I'm
slightly nuts. :)

- Gio

--
AND NOW FOR A WORD (an IF blog):

http://giomancer.wordpress.com/
Jun 27 '08 #4
Ian Collins said:
Gio wrote:
<snip>
>main()

make that int main(void).

While you are there, turn your compiler's warnings up, the above should
have caused one.
Why?

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #5
Gio said:
>While you are there, turn your compiler's warnings up, the above
should have caused one.

Well.. ah.. I'm working on an Apple II; the compiler I ran this program
on is technically pre-ANSI, but I've kept the differences in mind (and
the documentation close at hand). I figured I could ask a K&R question,
though.
You can. K&R C is topical here, although some people here tend to forget
that.
>
As to why I'm learning C on an Apple IIe.. I'm doing it to get used to
the compiler and the limitations of the computer. And because I'm
slightly nuts. :)
....and of course it is *not* comp.lang.c's place to dictate to you what
compiler you must use. Some of the people here occasionally forget that,
too.

(There are, however, definite advantages to be had in bringing yourself
kicking and screaming into the late 1980s. The ANSI C Standard of 1989 was
a significant step forward for C.)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #6
Gio
printf("%4s %7s\n", "F", "C");

Aha! This is perfect for me, thank you! I didn't know that it could work
like that. :p

- Gio

--
AND NOW FOR A WORD (an IF blog):

http://giomancer.wordpress.com/
Jun 27 '08 #7
Richard Heathfield wrote:
Ian Collins said:
>Gio wrote:

<snip>
>>main()
make that int main(void).

While you are there, turn your compiler's warnings up, the above should
have caused one.

Why?
You know why.

--
Ian Collins.
Jun 27 '08 #8
Ian Collins said:
Richard Heathfield wrote:
>Ian Collins said:
>>Gio wrote:

<snip>
>>>main()
make that int main(void).

While you are there, turn your compiler's warnings up, the above
should have caused one.

Why?
You know why.
If I knew why, I wouldn't need to ask why. I can see no reason why main()
should require a K&R C implementation (such as the OP is using) to issue a
diagnostic message. Please explain.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #9
Richard Heathfield wrote:
Ian Collins said:
>Richard Heathfield wrote:
>>Ian Collins said:

Gio wrote:
<snip>

main()
make that int main(void).

While you are there, turn your compiler's warnings up, the above
should have caused one.
Why?
You know why.

If I knew why, I wouldn't need to ask why. I can see no reason why main()
should require a K&R C implementation (such as the OP is using) to issue a
diagnostic message. Please explain.
The OP didn't say he was using such an old compiler until his reply to
my post.

--
Ian Collins.
Jun 27 '08 #10
On Apr 19, 8:33*pm, Ian Collins <ian-n...@hotmail.comwrote:
Richard Heathfield wrote:
Ian Collins said:
Gio wrote:
<snip>
>main()
make that int main(void).
While you are there, turn *your compiler's warnings up, the above should
have caused one.
Why?

You know why.

--
Ian Collins.
Not on a K&R Compiler. Also warning levels not available on this
particular compiler, however 60% of Apple II developers wrote in Aztec
C. During the mid 80's Aztec C was the largesty selling C compiler.
And the best C compiler of the 80's and perhaps of all time.

Go to the Aztec C Website and take a look:

http://www.clipshop.ca/Aztec/index.htm

Bill Bucxels
Jun 27 '08 #11
Bill Buckels wrote:
On Apr 19, 8:33 pm, Ian Collins <ian-n...@hotmail.comwrote:
>Richard Heathfield wrote:
>>Ian Collins said:
Gio wrote:
<snip>
main()
make that int main(void).
While you are there, turn your compiler's warnings up, the above should
have caused one.
Why?
You know why.
*Please* don't quote signatures.
>
Not on a K&R Compiler.
See my reply to Richard.

--
Ian Collins.
Jun 27 '08 #12
Ian Collins said:
Richard Heathfield wrote:
>Ian Collins said:
>>Richard Heathfield wrote:
Ian Collins said:

Gio wrote:
<snip>

>main()
make that int main(void).
>
While you are there, turn your compiler's warnings up, the above
should have caused one.
Why?

You know why.

If I knew why, I wouldn't need to ask why. I can see no reason why
main() should require a K&R C implementation (such as the OP is using)
to issue a diagnostic message. Please explain.
The OP didn't say he was using such an old compiler until his reply to
my post.
<shrugThat would be fair enough, if the same point didn't apply to C90
implementations. It would appear from your reply that you assumed, against
the balance of reasonable probability, that he was using a conforming C99
implementation!

Look, if your point is that the int main(void) form is *preferable*, I
agree completely. I use that form myself and recommend it to others. But
there's quite a lot of distance between "this form is preferred to that
form" and "that form should have caused the implementation to issue a
diagnostic message".

Furthermore, K&R C implementations do not, as far as I'm aware, necessarily
support the void keyword (although I accept that it is not reasonable to
expect you to have taken *that* into account in your original reply).

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #13
Gio
There are, however, definite advantages to be had in bringing
yourself kicking and screaming into the late 1980s. The ANSI C
Standard of 1989 was a significant step forward for C.
*nods* My first experience with coding was a CS class in college; they
taught ANSI C (ISO C was, I think, a year away). The person that makes
the compiler I'm using (Aztec-C) available has been talking to the
company that owns it to see if he can get the source and update it to
ANSI standards.

There is another compiler for the Apple IIe called cc65. It's not too
bad, really, and it is (according to the webpage) almost conforming to
the ISO standard. The program from the K&R book would not compile in it
without modification. Unfortunately, I can't get its output file to run
under ProDOS, which is the OS of choice for the Apple IIe.

While that is probably a personal problem, I'm going down the path of
least resistance for now. :)

- Gio

--
AND NOW FOR A WORD (an IF blog):

http://giomancer.wordpress.com/
Jun 27 '08 #14
Ian Collins <ia******@hotmail.comwrites:
Gio wrote:
>I'm reading the K&R book and doing the exercises. Currently, I'm working
on Exercise 1-3.

Here's what I have:

[code]

#include <stdio.h>

main()

make that int main(void).

While you are there, turn your compiler's warnings up, the above should
have caused one.
[...]

For certain values of "should". A C90-conforming implementation is
not required to issue a diagnostic for that declaration of main,
though a decent one will do so anyway if you ask it nicely.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #15
Gio wrote:
>
>There are, however, definite advantages to be had in bringing
yourself kicking and screaming into the late 1980s. The ANSI C
Standard of 1989 was a significant step forward for C.

*nods* My first experience with coding was a CS class in college;
they taught ANSI C (ISO C was, I think, a year away). The person
that makes the compiler I'm using (Aztec-C) available has been
talking to the company that owns it to see if he can get the
source and update it to ANSI standards.
I seem to vaguely recall that the originator of Aztec C made its
source generally available some time ago. I was not interested, so
this may be in thorough error. You might ask on
alt.folklore.computers and comp.os.cpm.

BTW, please do not delete attribution lines for any material you
quote. Attribution lines are the ones that say "Joe wrote:" at the
beginning.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #16
Richard Heathfield wrote:
>
Look, if your point is that the int main(void) form is *preferable*, I
agree completely. I use that form myself and recommend it to others. But
there's quite a lot of distance between "this form is preferred to that
form" and "that form should have caused the implementation to issue a
diagnostic message".
Your recommended options for gcc would.

--
Ian Collins.
Jun 27 '08 #17
Gio wrote:

nods My first experience with coding was a CS class in college; they
taught ANSI C (ISO C was, I think, a year away). The person that
makes the compiler I'm using (Aztec-C) available has been talking to
the company that owns it to see if he can get the source and update
it to ANSI standards.
Aztec. Aztec. This sound familiar. Oh, aren't you the guy from RAIF
that was thinking of writing a text-adventure game to learn C?


Brian
Jun 27 '08 #18
Ian Collins said:
Richard Heathfield wrote:
>>
Look, if your point is that the int main(void) form is *preferable*, I
agree completely. I use that form myself and recommend it to others. But
there's quite a lot of distance between "this form is preferred to that
form" and "that form should have caused the implementation to issue a
diagnostic message".
Your recommended options for gcc would.
Perhaps. Again, however, there is no obligation on subscribers to this
group to use gcc.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #19
Gio
Oh, aren't you the guy from RAIF that was thinking of writing a
text-adventure game to learn C?
Yep! That's me. :) Good to see you! I recognize you as well.

My plans have changed a little; instead of making up a new game, I will
be porting over the original Adventure. :D

- Gio

--
AND NOW FOR A WORD (an IF blog):

http://giomancer.wordpress.com/
Jun 27 '08 #20
There are, however, definite advantages to be had in bringing
yourself kicking and screaming into the late 1980s. The ANSI C
Standard of 1989 was a significant step forward for C.
Given a choice between the best C compiler ever written for the Apple
II from the same company who produced the best C compilers ever
written, and trying to use a partially compliant ANSI 89 committee
animal that is hard if not harder to use and featureless by
comparison, I would argue that one should in fact not follow a gang of
kickers and screamers whether they have or not had the experience of
developing for older platforms as well as new, nor the wisdom to tell
the difference, or perhaps do know the difference but should not be
followed anyway.

K & R function prototypes are no problem. If that presents a problem
then one should probably consider taking up pizza delivery rather than
C programming.

I quite agree that in a perfect world the academic approach of using a
single standard would be wonderful, but since each case needs to be
considered on its own merit, probably less focus on what dialect of a
language is better, and since in many ways ANSI C extended K & R C, it
is not bad for a stranger in a strange land to learn to speak in
simple sentences before learning more complicated ones.

If you recall that a function is an int by default in K & R and so are
variables and these can be omitted and unsafely assumed to be int,
consider also that GIO does not need to omit types and can still
operate in a typesafe manner. He doesn't need to use typedefs and
return structures from functions.

Or didn't anyone who wrote a C program before 1989 do at least as good
a job as what I see around me today? You already know what I will say
when someone who has only been programming in C for 10 years or so
challenges me on this.

The examples that I have given him which by the way are also available
to anyone here who cares to look are pretty good. And he studied C as
well and from what I have seen so far he doesn't have much trouble
understanding.

http://www.clipshop.ca/Aztec/index.htm

Now until we can get the source code from Manx Software Systems which
looks like it will come if it still exists, I am not going to start
writing an ansi compliant replacement compiler for the Apple II.

Part of this work may even have been done for the Apple II according
to one of Manx's developers. We'll see. Until then Brodie's C89 was
significant but not currently an option here.

The benefit of having the source code for the Aztec C compilers for
the Apple II, Commodore 64, Amiga, Atari, Mac 68000, Z80 and 8080, and
of course 8086 MS-DOS and CP/M 86, and also of the linkers, the
library managers, symbolic debuggers, and all the rest of those first-
class cross-compilers and native-mode compilers, some which are
already ANSI 89 will be to make them available as cross-compilers for
such platforms as we wish. The Aztec C cross compilers that I have
currently only run in MS-DOS or CP/M.
The person that makes
the compiler I'm using (Aztec-C) available has been talking to the
company that owns it to see if he can get the source and update it to
ANSI standards.
That person would be me.
There is another compiler for the Apple IIe called cc65. It's not too
bad, really, and it is (according to the webpage) almost conforming to
the ISO standard. The program from the K&R book would not compile in it
without modification. Unfortunately, I can't get its output file to run
under ProDOS, which is the OS of choice for the Apple IIe.
Aztec C for the Apple II is "almost" ANSI but it's not.

But when it comes to compilers Aztec C is without equal. It was for
its time simnply the best and was squashed by some very giant
companies including Microsoft who once took out 6 full page ads in a
computer magazine to slam Aztec C.

For quite some time, around 85, 86, or so, it was the world's largest
selling C compiler.

The two unparalelled individuals behind its core were Thomas Fenwick
who later went on to write the CE Kernel, and James Goonow who then
worked with Carl Sassenrath on VIDStream and REBOL.

The floating point libraries at a time when FP was unheard of were
flawless and actually the 6 or so individuals that put these together
are like the whose-who of who invented floating point for compilers as
we know them.
While that is probably a personal problem, I'm going down the path of
least resistance for now. :)
I think that you aren't the person with the problem and I don't so
much think the problem with that compiler is personal so much as it
isn't finished. By contrast the Aztec C compiler for the Apple II was
used by 60% of the Apple II dvelopers.

We call the path of least reasistance the critical path and it is
always the best one to take because if it turns-out to be the wrong
one you will find-out sooner than the slower path with the most
resistance. Also as suggested perhaps a little more strongly than I
should have (perhaps not) if you can't just jump-in and start coding
then hiow are ya gonna get any learning done?

"All the tired horses in the sun, how'm'I 'sposed to get any riding
done?"

- Bob Dylan

Jun 27 '08 #21
On Apr 19, 11:15*pm, CBFalconer <cbfalco...@yahoo.comwrote:
I seem to vaguely recall that the originator of Aztec C made its
source generally available some time ago. *
No Harry didn't.

Jun 27 '08 #22
On Sun, 20 Apr 2008 00:34:39 +0000, Richard Heathfield wrote:
>Ian Collins said:
While you are there, turn your compiler's warnings up, the above should
have caused one.
Why?

so any ANSI C conforming compiler is not required to issue a warning ?
GCC does that and I think it is a good idea:

"control reaches the end of a non-void function"
but GCC never gives the warning if I omit the void of main(void) ;)

--
http://lispmachine.wordpress.com/
my email ID is at the above address

Jun 27 '08 #23
arnuld said:
>On Sun, 20 Apr 2008 00:34:39 +0000, Richard Heathfield wrote:
>>Ian Collins said:
While you are there, turn your compiler's warnings up, the above
should have caused one.
>Why?


so any ANSI C conforming compiler is not required to issue a warning ?
Correct for C90 (but C99 dropped implicit int, so without doing anything so
radical as checking the grammar I would imagine that we're talking syntax
error, and that would require a diagnostic message - which can be, but
need not be, a warning).
GCC does that and I think it is a good idea:

"control reaches the end of a non-void function"
Strange - I get a different message. Here's my test program:

#include <stdio.h>

main()
{
puts("Hello, world");
return 0;
}

and here is gcc's output:

foo.c:4: warning: return-type defaults to `int'
foo.c:4: warning: function declaration isn't a prototype

This output is useful and informative - but it isn't mandatory. In C99, the
implementation must diagnose implicit int (assuming, as I said above, that
it is in fact a syntax error or, perhaps, a constraint violation). But in
C90 and prior, this is not the case.
but GCC never gives the warning if I omit the void of main(void) ;)
It does if you kick it hard enough (see above).

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #24
arnuld wrote:
Richard Heathfield wrote:
Ian Collins said:
While you are there, turn your compiler's warnings up,
the above should have caused one.
Why?

so any ANSI C conforming compiler is not required to issue
a warning ?
Compilers talk in terms of warnings and errors. The standard
talks only of diagnostics, some of which are required. There
is no direct correlation between the two worlds except that
an 'error' tends to cause compilation to fail.

In clc it is better to talk of required diagnostics which are those
that a conforming implementation are required to issue (at
least one of) when encountering a constraint violation.

Whether required diagnostics become errors or warnings
is entirely a matter for the implementation writer. The
standard just needs the implementation to go 'beep'! :-)
GCC does that and I think it is a good idea:

"control reaches the end of a non-void function"
In C, non-void functions are not required to return a value.
So this should be a warning in most cases. If it's an error,
then the compiler needs to prove that there exists a function
that attempts to use the return value after calling the non-
void function that doesn't return a value.
but GCC never gives the warning if I omit the void of
main(void) ;)
Turn up your warning levels then.

--
Peter
Jun 27 '08 #25
On Mon, 21 Apr 2008 05:21:00 +0000, Richard Heathfield wrote:

Strange - I get a different message. Here's my test program:
...[SNIP]........
foo.c:4: warning: return-type defaults to `int'
foo.c:4: warning: function declaration isn't a prototype
I have seen this warning with GCC at my home, did not remember which
version it was. Right now at company's workstation it is GCC 3.4.

It does if you kick it hard enough (see above).
tried even -std=c99 flag, still no luck
--
http://lispmachine.wordpress.com/
my email ID is at the above address

Jun 27 '08 #26
arnuld wrote:
>On Mon, 21 Apr 2008 05:21:00 +0000, Richard Heathfield wrote:

>Strange - I get a different message. Here's my test program:
>...[SNIP]........

>foo.c:4: warning: return-type defaults to `int'
foo.c:4: warning: function declaration isn't a prototype

I have seen this warning with GCC at my home, did not remember which
version it was. Right now at company's workstation it is GCC 3.4.

>It does if you kick it hard enough (see above).

tried even -std=c99 flag, still no luck
Are you using -Wall -W and -pedantic flags?

Jun 27 '08 #27
On Apr 21, 12:24*am, Peter Nilsson <ai...@acay.com.auwrote:
Turn up your warning levels then.
But GCC already does provide a very interesting warning which to me is
irrelevant:

C:\gcc>gcc test.c -o test.exe
test.c:7:2: warning: no newline at end of file

C:\gcc>test
foo

here's the code:

#include <stdio.h>

main()
{
puts("foo");
return 0;
}

Note: do not press enter above.

Microsoft C has no problems with any of that:

C:\gcc>cl test.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42
for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

test.c
Microsoft (R) Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

/out:test.exe
test.obj

C:\gcc>test
foo

Until we turne-up the Warning Level

C:\gcc>cl test.c -W4
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.42
for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.

test.c
test.c(4) : warning C4431: missing type specifier - int assumed. Note:
C no longer supports default-int
Microsoft (R) Incremental Linker Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.

/out:test.exe
test.obj

However even --help using gcc failed to reveal how to set a higher
warning level and either one shoudl assume that gcc does not support
warning levels or considers these to be irrelevant and newlines at the
end of a file to be relevant.

Microsoft C has no problem providing information on how to use warning
levels with their compiler from the command line.

I believe that a comment was made here about trying to find someone a
better compiler. Suggest you all might want to try Microsoft C for a
better compiler:)

Regards,

Bill Buckels



Jun 27 '08 #28
On Mon, 21 Apr 2008 03:07:27 -0700, Bill Buckels wrote:
But GCC already does provide a very interesting warning which to me is
irrelevant:

C:\gcc>gcc test.c -o test.exe
test.c:7:2: warning: no newline at end of file
where are the warning flags ?

gcc -std=x -pedantic -Wall -Wextra file.c

x = c89 or c99
here's the code:

#include <stdio.h>

main()
{
puts("foo");
return 0;
}
[arnuld@raj C]$ gcc -ansi -pedantic -Wall -Wextra test.c
test.c:7: warning: return type defaults to `int'

thats a good warning I think, and YES, I followed your next instruction:

"Note: do not press enter above"

Microsoft C has no problems with any of that:
2 years ago, I stopped using any products from Microsoft and from that
time my general idea about both computers and programming have gone wider
and better and of good amount of depth.

--
http://lispmachine.wordpress.com/
my email ID is at the above address

Jun 27 '08 #29
On Apr 21, 5:07*am, Bill Buckels <bbuck...@escape.cawrote:
I believe that a comment was made here about trying to find someone a
better compiler. Suggest you all might want to try Microsoft C for a
better compiler:)
Actually it was "more decent" compiler but IMNSHO the OP meant
"better"!
Jun 27 '08 #30
On Apr 21, 10:55*am, arnuld <NoS...@NoPain.Romewrote:
2 years ago, I stopped using any products from Microsoft and from that
time my general idea about both computers and programming have gone wider
and better and of good amount of depth. *
Of course my Dear Fellow, I feel the enlightenment shining from my CRT
but we used to call that "irradiation". I have only been using gcc for
over 10 years and have been programming in C for almost 30 years so my
perspective is obviously not as valid. I have about 100 C compilers
installed on this toy box at home, so I can see how shallow my depth
has grown. You make a good point.

And when groups of these individuals who have transcended gather
together it is always fine to say that compiler X is better than MSC
or compiler Y is better than Aztec C but never the other way around.

Regards,

Bill Buckels

Jun 27 '08 #31
On Mon, 21 Apr 2008 15:33:20 +0530, santosh wrote:

Are you using -Wall -W and -pedantic flags?
gcc -ansi -pedantic -Wall -Wextra
--
http://lispmachine.wordpress.com/
my email ID is at the above address

Jun 27 '08 #32
On Mon, 21 Apr 2008 03:51:09 -0700, Bill Buckels wrote:

Of course my Dear Fellow, I feel the enlightenment shining from my CRT
but we used to call that "irradiation". I have only been using gcc for
over 10 years and have been programming in C for almost 30 years so my
perspective is obviously not as valid. I have about 100 C compilers
installed on this toy box at home
:-O

And when groups of these individuals who have transcended gather
together it is always fine to say that compiler X is better than MSC
or compiler Y is better than Aztec C but never the other way around.

I am sure I can't follow you here but that is quite OT discussion. So I
simply stop here.

--
http://lispmachine.wordpress.com/
my email ID is at the above address

Jun 27 '08 #33
Bill Buckels said:
On Apr 21, 12:24 am, Peter Nilsson <ai...@acay.com.auwrote:
>Turn up your warning levels then.

But GCC already does provide a very interesting warning which to me is
irrelevant:

C:\gcc>gcc test.c -o test.exe
test.c:7:2: warning: no newline at end of file
It's not irrelevant, however, to those who need their code to conform to
ISO C. "A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character", says
the Standard.

<snip>
However even --help using gcc failed to reveal how to set a higher
warning level and either one shoudl assume that gcc does not support
warning levels or considers these to be irrelevant and newlines at the
end of a file to be relevant.
Try these to be going on with...

-W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align -Wpointer-arith
-Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes
-Wmissing-declarations -Winline -Wundef -Wnested-externs -Wcast-qual
-Wshadow -Wconversion -Wwrite-strings -ffloat-store -fno-builtin -O2

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #34
Bartc wrote:
>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:JL******************************@bt.com...
>Bill Buckels said:
>>However even --help using gcc failed to reveal how to set a higher
warning level and either one shoudl assume that gcc does not support
warning levels or considers these to be irrelevant and newlines at
the end of a file to be relevant.

Try these to be going on with...

-W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-ffloat-store -fno-builtin -O2

OK, but how do you get gcc to tell you all these things?
info gcc if you have installed it's documentation, which is almost
always true.

Otherwise you can download the complete documentation for your version
from the GNU GCC website in multiple formats like HTML or PDF.

<http://gcc.gnu.org/onlinedocs/>
Gcc is either
very unfriendly or assumes everyone knows this stuff.
It's one of the most intuitive compilers I have worked with.
Or perhaps it's
buried in the 11000 lines of man info I once saw (I now use gcc/mingw
so no man command).
Cygwin might be a fuller UNIX environment.
Sometimes there is an advantage to using a simple compiler like, say,
lccwin32.
Not in this case though. The main advantage of lcc-win32 is ease of
download and installation and the fact that it includes things like
IDE, debugger etc.

Jun 27 '08 #35
"Bartc" <bc@freeuk.comwrites:
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:JL******************************@bt.com...
>Bill Buckels said:
>>However even --help using gcc failed to reveal how to set a higher
warning level and either one shoudl assume that gcc does not support
warning levels or considers these to be irrelevant and newlines at the
end of a file to be relevant.

Try these to be going on with...

-W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align -Wpointer-arith
-Wbad-function-cast -Wmissing-prototypes -Wstrict-prototypes
-Wmissing-declarations -Winline -Wundef -Wnested-externs -Wcast-qual
-Wshadow -Wconversion -Wwrite-strings -ffloat-store -fno-builtin -O2

OK, but how do you get gcc to tell you all these things? Gcc is either very
unfriendly or assumes everyone knows this stuff. Or perhaps it's buried in
the 11000 lines of man info I once saw (I now use gcc/mingw so no man
command).
Or perhaps its just a question for typing

"gcc --help" and reading what it says?

From there we get

gcc -v --help

Although google is your friend too and the heaps of detailed help out
there on the web.
With power comes responsibility :-;
Jun 27 '08 #36
Bartc said:
>
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:JL******************************@bt.com...
>>
Try these to be going on with...

-W -Wall -ansi -pedantic -Wformat-nonliteral -Wcast-align
-Wpointer-arith -Wbad-function-cast -Wmissing-prototypes
-Wstrict-prototypes -Wmissing-declarations -Winline -Wundef
-Wnested-externs -Wcast-qual -Wshadow -Wconversion -Wwrite-strings
-ffloat-store -fno-builtin -O2

OK, but how do you get gcc to tell you all these things?
man gcc

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #37

"Bartc" <bc@freeuk.comwrote in message
news:9R******************@text.news.virginmedia.co m...

[Getting gcc to show warning options]

"santosh" <sa*********@gmail.comwrote in message
news:fu**********@registered.motzarella.org...
info gcc if you have installed it's documentation, which is almost
always true.
I assumed that this 50MB download would include basic docs! No info command
but I did find gcc.info which explained the options.

"Richard" <de***@gmail.comwrote in message
news:fu**********@registered.motzarella.org...
>Or perhaps its just a question for typing
"gcc --help" and reading what it says?
OK, after (the first time) trying the options -h, --h, -help,
finally --help, it shows:

" --target-help Display target specific command line options
(Use '-v --help' to display command line options of sub-processes)"

Nothing to indicate this will be very useful, but even if I try -v --help, I
get 1000 or 2000 lines of information, which mentions -Wall for example but
doesn't explain it.

"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:pJ******************************@bt.com...
man gcc
Not on my version (this is on Windows).

So I still maintain the compiler is not very helpful.

Such basic information should be readily available without needing to look
elsewhere, or wading through tons of docs.

--
Bart

Jun 27 '08 #38
"Bartc" <bc@freeuk.comwrites:
"Bartc" <bc@freeuk.comwrote in message
news:9R******************@text.news.virginmedia.co m...

[Getting gcc to show warning options]

"santosh" <sa*********@gmail.comwrote in message
news:fu**********@registered.motzarella.org...
>info gcc if you have installed it's documentation, which is almost
always true.

I assumed that this 50MB download would include basic docs! No info command
but I did find gcc.info which explained the options.

"Richard" <de***@gmail.comwrote in message
news:fu**********@registered.motzarella.org...
>>Or perhaps its just a question for typing
"gcc --help" and reading what it says?

OK, after (the first time) trying the options -h, --h, -help,
finally --help, it shows:

" --target-help Display target specific command line options
(Use '-v --help' to display command line options of sub-processes)"

Nothing to indicate this will be very useful, but even if I try -v --help, I
get 1000 or 2000 lines of information, which mentions -Wall for example but
doesn't explain it.
Then you need to refer to the manual. It's not going to hold your hand
:-; GCC is a powerful program - you need to respect that.

Good luck!
Jun 27 '08 #39
Bartc wrote:
>
"Bartc" <bc@freeuk.comwrote in message
news:9R******************@text.news.virginmedia.co m...

[Getting gcc to show warning options]

"santosh" <sa*********@gmail.comwrote in message
news:fu**********@registered.motzarella.org...
>info gcc if you have installed it's documentation, which is almost
always true.

I assumed that this 50MB download would include basic docs! No info
command but I did find gcc.info which explained the options.
Hmm. It's some time since I was involved with Windows so I do not
remember what exactly MinGW included by the way of documentation. I do
know that DJGPP includes the full set of documentation (if you opt to
select it during download) along with the 'man' and 'info' commands to
read them. Cygwin also has just about everything that you would expect
to find with a UNIX gcc installation. As a last resort you'll have to
download gcc's manuals available at the site I included a link to in my
previous post.

If I recall correctly, MinGW includes it's own implementation of the
standard library which presumably includes the documentation too.
Otherwise the Dinkumware site is a great resource for this.
"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:pJ******************************@bt.com...
>man gcc

Not on my version (this is on Windows).

So I still maintain the compiler is not very helpful.

Such basic information should be readily available without needing to
look elsewhere, or wading through tons of docs.
Note that the GCC project is quite separate from the MinGW project. It's
rather uncharitable to blame the former for the deficiencies of the
latter. Similarly DJGPP and Cygwin are also not connected with the GNU
GCC project except for the fact of a shared code base.

Jun 27 '08 #40
On Apr 21, 10:32*am, "Bartc" <b...@freeuk.comwrote:
[sip]
"Richard Heathfield" <r...@see.sig.invalidwrote in message

news:pJ******************************@bt.com...
man gcc

Not on my version (this is on Windows).

So I still maintain the compiler is not very helpful.

Such basic information should be readily available without needing to look
elsewhere, or wading through tons of docs.
Try:
info gcc
Jun 27 '08 #41
On Mon, 21 Apr 2008 17:32:28 +0000, Bartc wrote:

Such basic information should be readily available without needing to
look elsewhere, or wading through tons of docs.

you have to. Every piece of software is its creator's vision. Some
visions are good and some are literally much worse misfortunes of
human history. Regarding GCC, I think -Wall and -Wextra will be enough
unless you have some very-specific requirements, in this case you have to
dig the documentation or better search the GCC mailing lists first for if
someone already posted about the same requirements as yours.

In the end, RMS is one of best Hackers you will ever come across in your
lifetime.

--
http://lispmachine.wordpress.com/
my email ID is at the above address

Jun 27 '08 #42

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

Similar topics

9
by: Collin VanDyck | last post by:
I have a basic understanding of this, so forgive me if I am overly simplistic in my explanation of my problem.. I am trying to get a Java/Xalan transform to pass through a numeric character...
1
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a...
0
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a...
4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: ...
4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
11
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
7
by: John Nagle | last post by:
I've been parsing existing HTML with BeautifulSoup, and occasionally hit content which has something like "Design & Advertising", that is, an "&" instead of an "&amp;". Is there some way I can get...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.