[OT] lcc first experience

Discussion in 'C Programming' started by Morris Dovey, May 6, 2008.

  1. Morris Dovey

    Morris Dovey Guest

    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

    Morris Dovey, May 6, 2008
    1. Advertisements

  2. 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

    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;
    Tomás Ó hÉilidhe, May 6, 2008
    1. Advertisements

  3. Morris Dovey

    Morris Dovey Guest

    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, May 6, 2008
  4. Yeah, gotta hate all that superfluous shite that does absolutely nothing
    except let you debug your program.
    Antoninus Twink, May 6, 2008
  5. [...]

    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.

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

    Keith Thompson, May 6, 2008
  6. Morris Dovey

    jacob navia Guest

    Thank you. Really. It is nice to see that my effort is
    good for users.
    jacob navia, May 6, 2008

  7. 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();
    Tomás Ó hÉilidhe, May 6, 2008
  8. Ehrm, the "-S" parameter creates assembly output - are you sure that the
    compiled executable works?

    Kind Regards,
    Johannes Bauer, May 6, 2008

  9. Wups I meant a lowercase S. Also I use -Wall.
    Tomás Ó hÉilidhe, May 6, 2008
  10. Because 0b is not standard C, and is an lcc-win extension ?
    Walter Roberson, May 7, 2008
  11. Morris Dovey

    vippstar Guest

    Because 0b is not standard C. If you want a standard C solution, take
    a loot at
    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.
    vippstar, May 7, 2008
  12. Morris Dovey

    Paul Hsieh Guest

    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, May 7, 2008
  13. Morris Dovey

    dj3vande Guest

    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'.)

    dj3vande, May 7, 2008
  14. Morris Dovey

    Bart Guest

    You mean 0x40 or decimal 64?
    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.
    Bart, May 7, 2008
  15. Morris Dovey

    jacob navia Guest

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


    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.
    I do not know why this is not used elsewhere.
    jacob navia, May 7, 2008
  16. [...]

    Ada supports all bases 2 through 16:

    2#11001001# -- binary
    3#12012# -- trinary (ternary?)
    10#42# -- equivalent to just 42
    16#1.23#e10 -- hexadecimal floating-point (1.13671875 * 16**10)

    One advantage is uniformity; there's no special-case syntax for each
    base. On the other hand,

    And Perl supports C-style literals plus binary with the "0b..."
    I don't suggest that C needs this much generality (even in Ada, I've
    rarely if ever seen bases other than 2, 8, 10, and 16 outside test
    cases). But IMHO binary constants using the 0b syntax would be a nice
    addition, requiring only minor changes to the compiler and to the
    runtime library. On the other hand, we've gotten along for decades
    without them, and new features quite properly need to meet a high
    burden before being standardized.
    Keith Thompson, May 8, 2008
  17. Morris Dovey

    Chris Torek Guest


    One could squeeze arbitrary integer bases into C (as it stands
    today) using (eg) 0r, with the radix and number separated by another
    punctuator that can be found in what is currently a valid "pp-number"
    but not-valid integer, e.g., another r, or a decimal point, or
    some such:


    Not only have I wanted them, I have even implemented them (though
    not in C). However:
    as it turns out, binary constants like this are actually quite
    error-prone. I discovered it was better to go back to hexadecimal
    constants in quite a few cases. The binary constants were mainly
    useful in short binary numbers (where hex-vs-binary became pretty
    much a matter of taste).

    If C were to steal another feature from Ada, we could fix this,
    *and* the equivalent problem with other large constants (in any
    base), by adding "_" as an ignored digit separator. Then we could




    both of which are (I believe) superior to the equivalent versions
    without underscores. I also find:


    a little more "obvious" than:


    Note that C89's "pp-number" tokens leave enough leeway to add both
    binary constants (with 0b) *and* group separators (with _). Perhaps
    I should add them to gcc (with an appropriate "extension" warning),
    and try to get them into C1x. :)
    Chris Torek, May 8, 2008
  18. Morris Dovey

    Richard Bos Guest

    Because the author of lcc-win-32 is a great adherent of the embrace-and-
    extend philosophy; IOW, a disciple of Microsoft and GnuC.

    Richard Bos, May 8, 2008
  19. Also Algol 68, which supports all bases <= 36, not only those four.
    Dik T. Winter, May 8, 2008
  20. As does Common Lisp.

    -- Richard
    Richard Tobin, May 8, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.