PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.c > [OT] lcc first experience
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
[OT] lcc first experience

Réponse
 
LinkBack Outils de la discussion
Vieux 06/05/2008, 18h33   #1
Morris Dovey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut [OT] lcc first experience

About a week ago, I downloaded Jacob's lcc package to my new (to me)
Win/XP box and gave it a test drive this morning. The application
program reads my web server's log file (currently about 35MB) and
reduces it to a bunch of lists, then outputs the log contents arranged
by each requestor's chronological list of hits. It's not really a
strenuous test, but there's plenty of opportunity to screw up multiple
levels of indirection, etc.

The program was originally written on a Linux system and compiled/linked
using the gcc toolchain.

With the "pedantic" option it warned (8 times) about "Assignment within
a conditional expression" but was otherwise friendly. The executable was
some larger than I recollected the gcc version had been, but shrank by
8KB when I used the -O (peephole optimizer) option. I think that puts
the size in the same ballpark with the gcc-compiled (with -O3) version.

The only other C compiler I have for my current environment is TurboC
V3.0 - an old friend, but not always convenient in current MS platforms.
Unless I discover a particular need to use TC3 (or discover some
horrible in lcc), I'll probably stick with lcc.

My application (written in standard-compliant C, of course <g>) ported
without any change and ran without any problem.

I read comment in another thread that prompted me to comment and say to
Jacob:

Merci/Thanks/Gracas/Gracias/Ashkurak/Spasibo!

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
  Réponse avec citation
Vieux 06/05/2008, 18h41   #2
Tomás Ó hÉilidhe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

On May 6, 6:33pm, Morris Dovey <mrdo...@iedu.com> wrote:

> The executable was
> some larger than I recollected the gcc version had been, but shrank by
> 8KB when I used the -O (peephole optimizer) option.



Did you strip the executable, i.e. take out all the superfluous shite
that isn't needed? When using gcc, here's what I do to get a lean
executable:

gcc hello.c -D NDEBUG -ansi -pedantic -S -O3 -o hello.exe

It gave me an executable of 397 bytes for the follow program:

#include <stdio.h>

int main(void)
{
puts("Hello World!");
return 0;
}



  Réponse avec citation
Vieux 06/05/2008, 19h02   #3
Morris Dovey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

Tomás Ó hÉilidhe wrote:

> Did you strip the executable, i.e. take out all the superfluous shite
> that isn't needed?


I don't remember, but I'll check when I'm next on that machine (it's 16
miles from here at my shop). I've liked using gcc on the Linux box - and
expect that I'll enjoy using lcc on this one.

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
  Réponse avec citation
Vieux 06/05/2008, 19h10   #4
Antoninus Twink
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

On 6 May 2008 at 17:41, Tomás Ó hÉilidhe wrote:
> Did you strip the executable, i.e. take out all the superfluous shite
> that isn't needed?


Yeah, gotta hate all that superfluous shite that does absolutely nothing
except let you debug your program.

  Réponse avec citation
Vieux 06/05/2008, 19h19   #5
Keith Thompson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] lcc first experience

Morris Dovey <mrdovey@iedu.com> writes:
> About a week ago, I downloaded Jacob's lcc package to my new (to me)
> Win/XP box and gave it a test drive this morning.

[...]

jacob's compiler is called "lcc-win". "lcc" is a different compiler
(the one on which lcc-win was based). It's an important distinction.

[...]

> With the "pedantic" option it warned (8 times) about "Assignment
> within a conditional expression" but was otherwise friendly.


Such a warning seems perfectly friendly to me. Would you prefer that
it didn't tell you that you might have mistyped "==" as "="?

[snip]

--
Keith Thompson (The_Other_Keith) <kst-u@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
  Réponse avec citation
Vieux 06/05/2008, 19h21   #6
Morris Dovey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

Antoninus Twink wrote:
> On 6 May 2008 at 17:41, Tomás Ó hÉilidhe wrote:
>> Did you strip the executable, i.e. take out all the superfluous shite
>> that isn't needed?

>
> Yeah, gotta hate all that superfluous shite that does absolutely nothing
> except let you debug your program.


I don't much worry about it. Since loading Red Hat's v4.1 on the shop
computer, I've run gdb exactly once - because I thought I should try it
out for the experience (just in case).

Never needed it. Still - it's there if the need does arise.

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
  Réponse avec citation
Vieux 06/05/2008, 19h26   #7
jacob navia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] lcc first experience

Morris Dovey wrote:
> About a week ago, I downloaded Jacob's lcc package to my new (to me)
> Win/XP box and gave it a test drive this morning. The application
> program reads my web server's log file (currently about 35MB) and
> reduces it to a bunch of lists, then outputs the log contents arranged
> by each requestor's chronological list of hits. It's not really a
> strenuous test, but there's plenty of opportunity to screw up multiple
> levels of indirection, etc.
>
> The program was originally written on a Linux system and compiled/linked
> using the gcc toolchain.
>
> With the "pedantic" option it warned (8 times) about "Assignment within
> a conditional expression" but was otherwise friendly. The executable was
> some larger than I recollected the gcc version had been, but shrank by
> 8KB when I used the -O (peephole optimizer) option. I think that puts
> the size in the same ballpark with the gcc-compiled (with -O3) version.
>
> The only other C compiler I have for my current environment is TurboC
> V3.0 - an old friend, but not always convenient in current MS platforms.
> Unless I discover a particular need to use TC3 (or discover some
> horrible in lcc), I'll probably stick with lcc.
>
> My application (written in standard-compliant C, of course <g>) ported
> without any change and ran without any problem.
>
> I read comment in another thread that prompted me to comment and say to
> Jacob:
>
> Merci/Thanks/Gracas/Gracias/Ashkurak/Spasibo!
>


Thank you. Really. It is nice to see that my effort is
good for users.


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
  Réponse avec citation
Vieux 06/05/2008, 19h47   #8
Tomás Ó hÉilidhe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

On May 6, 7:19pm, Keith Thompson <ks...@mib.org> wrote:

> Such a warning seems perfectly friendly to me. Would you prefer that
> it didn't tell you that you might have mistyped "==" as "="?



I love what gcc has to say about it:

warning: suggest parentheses around assignment used as truth value

I've actually taken its advice and started doing:

if ((i=5)) DoWhatever();
  Réponse avec citation
Vieux 06/05/2008, 19h49   #9
Morris Dovey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] lcc first experience

Keith Thompson wrote:
> Morris Dovey <mrdovey@iedu.com> writes:
>> About a week ago, I downloaded Jacob's lcc package to my new (to me)
>> Win/XP box and gave it a test drive this morning.

> [...]
>
> jacob's compiler is called "lcc-win". "lcc" is a different compiler
> (the one on which lcc-win was based). It's an important distinction.


Hmm - ok. It does identify itself as lcc-win32, but the executable is
lcc.exe - I'll keep the distinction in mind. Thanks.

>> With the "pedantic" option it warned (8 times) about "Assignment
>> within a conditional expression" but was otherwise friendly.

>
> Such a warning seems perfectly friendly to me. Would you prefer that
> it didn't tell you that you might have mistyped "==" as "="?


Yes, unless I've actually made a mistake <vbg>

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
  Réponse avec citation
Vieux 06/05/2008, 19h51   #10
Johannes Bauer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

Tomás Ó hÉilidhe schrieb:

> gcc hello.c -D NDEBUG -ansi -pedantic -S -O3 -o hello.exe


Ehrm, the "-S" parameter creates assembly output - are you sure that the
compiled executable works?

Kind Regards,
Johannes

--
"Wer etwas kritisiert muss es noch lange nicht selber besser können. Es
reicht zu wissen, daß andere es besser können und andere es auch
besser machen um einen Vergleich zu bringen." - Wolfgang Gerber
in de.sci.electronics <47fa8447$0$11545$9b622d9e@news.freenet.de>
  Réponse avec citation
Vieux 06/05/2008, 21h48   #11
Malcolm McLean
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] lcc first experience


"Morris Dovey" <mrdovey@iedu.com> wrote in message
> About a week ago, I downloaded Jacob's lcc package to my new (to me)
> Win/XP box and gave it a test drive this morning.

The compiler works. Which should be par for the course, though given some of
the comments you hear in this forum you'd think there was a doubt about
that.


--
Free games and programming goodies.
http://www.personal.leeds.ac.uk/~bgy1mm

  Réponse avec citation
Vieux 06/05/2008, 23h35   #12
Tomás Ó hÉilidhe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

On May 6, 7:51pm, Johannes Bauer <dfnsonfsdu...@gmx.de> wrote:
> Tomás Ó hÉilidhe schrieb:
>
> > gcc hello.c -D NDEBUG -ansi -pedantic -S -O3 -o hello.exe

>
> Ehrm, the "-S" parameter creates assembly output - are you sure that the
> compiled executable works?



Wups I meant a lowercase S. Also I use -Wall.
  Réponse avec citation
Vieux 07/05/2008, 16h51   #13
nembo kid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] lcc first experience

Morris Dovey ha scritto:

> My application (written in standard-compliant C, of course <g>) ported
> without any change and ran without any problem.



Try do declare a define something like:


unsigned char a = 0b1000000;


With lcc-win works...with other compilers (i.e. mingw32-gcc) no...you
must use hexadecimal 0xF0 or decimal 128.

Why this?
  Réponse avec citation
Vieux 07/05/2008, 17h03   #14
Walter Roberson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] lcc first experience

In article <4821cf0c$0$40213$4fafbaef@reader5.news.tin.it>,
nembo kid <user@localhost.com> wrote:

>Try do declare a define something like:


>unsigned char a = 0b1000000;


>With lcc-win works...with other compilers (i.e. mingw32-gcc) no...you
>must use hexadecimal 0xF0 or decimal 128.


>Why this?


Because 0b is not standard C, and is an lcc-win extension ?

--
"MAMA: Oh--So now it's life. Money is life. Once upon a time freedom
used to be life--now it's money. I guess the world really do change.
WALTER: No--it was always money, Mama. We just didn't know about it."
-- Lorraine Hansberry
  Réponse avec citation
Vieux 07/05/2008, 17h24   #15
vippstar@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

On May 7, 6:51 pm, nembo kid <u...@localhost.com> wrote:
> Morris Dovey ha scritto:
>
> > My application (written in standard-compliant C, of course <g>) ported
> > without any change and ran without any problem.

>
> Try do declare a define something like:
>
> unsigned char a = 0b1000000;
>
> With lcc-win works...with other compilers (i.e. mingw32-gcc) no...you
> must use hexadecimal 0xF0 or decimal 128.
>
> Why this?


Because 0b is not standard C. If you want a standard C solution, take
a loot at
<http://cprog.tomsweb.net/binconst.txt>
With that header you can define a as:
unsigned char a = B8(10000000);
Also, if it works in compliant mode, then it's a bug.
  Réponse avec citation
Vieux 07/05/2008, 18h06   #16
Morris Dovey
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] lcc first experience

nembo kid wrote:
> Morris Dovey ha scritto:
>
>> My application (written in standard-compliant C, of course <g>) ported
>> without any change and ran without any problem.

>
> Try do declare a define something like:
>
> unsigned char a = 0b1000000;
>
> With lcc-win works...with other compilers (i.e. mingw32-gcc) no...you
> must use hexadecimal 0xF0 or decimal 128.
>
> Why this?


I think it's for programmers who can only count to one. :-)

--
Morris Dovey
DeSoto Solar
DeSoto, Iowa USA
http://www.iedu.com/DeSoto/
  Réponse avec citation
Vieux 07/05/2008, 18h52   #17
Paul Hsieh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

On May 6, 11:47 am, Tomás Ó hÉilidhe <t...@lavabit.com> wrote:
> On May 6, 7:19 pm, Keith Thompson <ks...@mib.org> wrote:
>
> > Such a warning seems perfectly friendly to me. Would you prefer that
> > it didn't tell you that you might have mistyped "==" as "="?

>
> I love what gcc has to say about it:
>
> warning: suggest parentheses around assignment used as truth value
>
> I've actually taken its advice and started doing:
>
> if ((i=5)) DoWhatever();


Whenever I do that I usually write it as:

if (0 != (i = 5)) DoWhatever();

to make it absolutely crystal clear what I mean.

--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
  Réponse avec citation
Vieux 07/05/2008, 18h58   #18
Eric Sosman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

Paul Hsieh wrote:
> On May 6, 11:47 am, Tomás Ó hÉilidhe <t...@lavabit.com> wrote:
>> On May 6, 7:19 pm, Keith Thompson <ks...@mib.org> wrote:
>>
>>> Such a warning seems perfectly friendly to me. Would you prefer that
>>> it didn't tell you that you might have mistyped "==" as "="?

>> I love what gcc has to say about it:
>>
>> warning: suggest parentheses around assignment used as truth value
>>
>> I've actually taken its advice and started doing:
>>
>> if ((i=5)) DoWhatever();

>
> Whenever I do that I usually write it as:
>
> if (0 != (i = 5)) DoWhatever();
>
> to make it absolutely crystal clear what I mean.


Wouldn't

i = 5;
DoWhatever();

be even more crystalline? Maybe a more believable example
might :

while (p = p->next) ...
vs.
while ( (p = p->next) ) ...
vs.
while ( (p = p->next) != NULL ) ...

--
Eric.Sosman@sun.com

  Réponse avec citation
Vieux 07/05/2008, 19h41   #19
dj3vande@csclub.uwaterloo.ca.invalid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

In article <1210183118.622176@news1nwk>,
Eric Sosman <Eric.Sosman@sun.com> wrote:

> Maybe a more believable example
>might :
>
> while (p = p->next) ...
>vs.
> while ( (p = p->next) ) ...
>vs.
> while ( (p = p->next) != NULL ) ...


For that particular case, I've found that
for(p=first; p; p=p->next)
usually makes more sense than using while, and has the bonus that I've
never seen a compiler complain about it.
(Depending on stylistic preferences, the second clause could also be
written as 'p != NULL' or 'NULL != p'.)


dave

--
Dave Vandervies dj3vande at eskimo dot com
Just about every state classifies bikes as vehicles, meaning that they ride
on roads and obey traffic laws (you'd never guess from the way most people
in this country ride bikes, though). --mark in rec.bicycles.misc
  Réponse avec citation
Vieux 07/05/2008, 21h28   #20
Joe Wright
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [OT] lcc first experience

nembo kid wrote:
> Morris Dovey ha scritto:
>
>> My application (written in standard-compliant C, of course <g>) ported
>> without any change and ran without any problem.

>
>
> Try do declare a define something like:
>
>
> unsigned char a = 0b1000000;
>
>
> With lcc-win works...with other compilers (i.e. mingw32-gcc) no...you
> must use hexadecimal 0xF0 or decimal 128.
>
> Why this?


I suppose 0xF0 is 240. 0x80 is 128 as is 0200. :-)

--
Joe Wright
"Everything should be made as simple as possible, but not simpler."
--- Albert Einstein ---
  Réponse avec citation
Vieux 07/05/2008, 21h59   #21
Bart
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

On May 7, 4:51pm, nembo kid <u...@localhost.com> wrote:
> Morris Dovey ha scritto:
>
> > My application (written in standard-compliant C, of course <g>) ported
> > without any change and ran without any problem.

>
> Try do declare a define something like:
>
> unsigned char a = 0b1000000;
>
> With lcc-win works...with other compilers (i.e. mingw32-gcc) no...you
> must use hexadecimal 0xF0 or decimal 128.


You mean 0x40 or decimal 64?

>
> Why this?


0b-syntax doesn't exist in standard C.

This actually tells you an awful lot about C and C programmers.

Implementing binary literals must take all of 10 minutes in a
compiler, but has rarely been done and is not part of any standard.

And it's not that it's never used; it just that C programmers prefer
to use ugly macros to writing straight code. Otherwise I'm sure a way
of writing binary constants (computers are binary, and C is low-level)
would have been standardised long ago.

Or, C programmers say to use hexadecimal instead!

lcc-win32 appears to have this 'extension' (if it's even that because
it's so trivial to implement), the problem being that the code won't
then compile anywhere else.


--
Bartc
  Réponse avec citation
Vieux 07/05/2008, 22h48   #22
CBFalconer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

Paul Hsieh wrote:
> Tomás Ó hÉilidhe <t...@lavabit.com> wrote:
>

.... snip ...
>
>> I've actually taken its advice and started doing:
>> if ((i=5)) DoWhatever();

>
> Whenever I do that I usually write it as:
> if (0 != (i = 5)) DoWhatever();
> to make it absolutely crystal clear what I mean.


FYI any non-zero integral value is taken as TRUE, while zero is
taken as FALSE, by all C logical expressions. So you don't need
the confusing extra garbage in the statement. The purpose of the
extra parentheses is only to suppress the gcc warning.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.


** Posted from http://www.teranews.com **
  Réponse avec citation
Vieux 07/05/2008, 23h55   #23
jacob navia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

Bart wrote:
> On May 7, 4:51 pm, nembo kid <u...@localhost.com> wrote:
>> Morris Dovey ha scritto:
>>
>>> My application (written in standard-compliant C, of course <g>) ported
>>> without any change and ran without any problem.

>> Try do declare a define something like:
>>
>> unsigned char a = 0b1000000;
>>
>> With lcc-win works...with other compilers (i.e. mingw32-gcc) no...you
>> must use hexadecimal 0xF0 or decimal 128.

>
> You mean 0x40 or decimal 64?
>
>> Why this?

>
> 0b-syntax doesn't exist in standard C.
>
> This actually tells you an awful lot about C and C programmers.
>
> Implementing binary literals must take all of 10 minutes in a
> compiler, but has rarely been done and is not part of any standard.
>


Excuse me that is not correct. Took around 30 minutes...

:-)


> And it's not that it's never used; it just that C programmers prefer
> to use ugly macros to writing straight code. Otherwise I'm sure a way
> of writing binary constants (computers are binary, and C is low-level)
> would have been standardised long ago.
>


This is just a facvility to users. As Mr Dovey proved, it is
VERY easy to get it wrong! It is the best to do it automatically.

> Or, C programmers say to use hexadecimal instead!
>
> lcc-win32 appears to have this 'extension' (if it's even that because
> it's so trivial to implement), the problem being that the code won't
> then compile anywhere else.
>


I do not know why this is not used elsewhere.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
  Réponse avec citation
Vieux 08/05/2008, 01h26   #24
CBFalconer
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

jacob navia wrote:
> Bart wrote:
>

.... snip about binary constants ...
>
> This is just a facvility to users. As Mr Dovey proved, it is
> VERY easy to get it wrong! It is the best to do it automatically.
>
>> Or, C programmers say to use hexadecimal instead!
>>
>> lcc-win32 appears to have this 'extension' (if it's even that
>> because it's so trivial to implement), the problem being that
>> the code won't then compile anywhere else.

>
> I do not know why this is not used elsewhere.


Simple. Because it is not required by the standard.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.


** Posted from http://www.teranews.com **
  Réponse avec citation
Vieux 08/05/2008, 01h32   #25
Eric Sosman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: lcc first experience

jacob navia wrote:
> [... concerning 0bXXXX... numeric literals ...]
> I do not know why this is not used elsewhere.


How about 0qXXXX...?

<off-topic>

In all my days, I've only encountered one language that
supported literals in all the bases 2,4,8,16: XPL, by McKeeman,
Horning, and Wortman.

binary: "(1)0101010101" (to any length desired)
quartal: "(2)11111" ( " " " " )
octal: "(3)0525" ( " " " " )
hex: "(4)155" ( " " " " )

The (4) could be omitted at the start of a hex bit-string.

The (2) constants were used a lot in their application,
which was an exemplar of compiler technology circa 1970.
A lot of it rested on tables of functions that had three
values ("stack, reduce, special case"), and these were
easily encoded (with some waste) as strings of base-four
numbers.

</off-topic>

--
Eric Sosman
esosman@ieee-dot-org.invalid
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 03h00.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,41183 seconds with 33 queries