Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers LCC > Is this a bug i...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 1021 of 1062
Post > Topic >>

Is this a bug in lcc-win32?

by Erwin Lindemann <elindema@[EMAIL PROTECTED] > Jan 28, 2008 at 02:59 AM

The program reproduced below has recently been posted in comp.lang.c,
but unfortunately when trying to compile it with lcc-win32, the
compilation aborts with an error. As pointed out in some of the
followups, it is believed the problem is with lcc-win32, and further
questions should be in this group.

It has been argued that the error is *not allowed* to show up with
'-ansic', but also that it *should not* show up without '-ansic'.

The error message is

----snip----
 lc -ansic -A -O -c ronu.c -o ronu.obj
Error ronu.c: 62  redefinition of 'ConstraintFailed'
Error c:\lcc\include\safelib.h: 3  Previous definition of
'ConstraintFailed' here
Warning ronu.c: 62  inconsistent linkage for 'ConstraintFailed' previously
declared at c:\lcc\include\safelib.h 3
2 errors, 1 warning
1 error
----snip----


Here is the complete program triggering the compile error, reproduced
with the author's permission:

----snip----
/*
 * runum.c
 *
 * Copyright (c) 2008, John J. Smith
 *
 * Permission to use, copy, modify, distribute, and sell this software 
 * and its do***entation for any purpose except in homework assignments 
 * is hereby granted without fee, provided that the above copyright 
 * notice appear in all copies and that both that copyright notice and 
 * this permission notice appear in sup****ting do***entation.
 *
 */

/*
 * Requirements:
 *
 * the program for converting the integers to roman
 * numerals using file(s) in the c language from 1-5000 range
 *
 */

#include <stdio.h>
#include <string.h>

/* 
 * the biggest foobarfoobar that foofoobarbar will accept
 */
#define MAX_FOOBARFOOBAR    5000

#define M   1000
#define D    500
#define C    100
#define L     50
#define X     10
#define V      5
#define I      1
#define N      0

/*
 * struct: foofoofoofoo
 *
 * purpose: map foofoofoobar values to their corresponding
 *          foofoobarfoo values
 *
 */
#define M1(a)   { #a , (a) }
#define M2(a,b) { #a #b , (b)-(a) }

static struct { 
    char *foofoofoobar;
    int foofoobarfoo;
} foofoofoofoo[] = { 
    M1(M),M2(C,M),M1(D),M2(C,D),M1(C),M2(X,C),M1(L),
    M2(X,L),M1(X),M2(I,X),M1(V),M2(I,V),M1(I),M1(N),
};
#define N_FOOFOOFOOFOO \
    ((sizeof foofoofoofoo) / (sizeof foofoofoofoo[0]))

#undef M1
#undef M2

static int ConstraintFailed(void) { return -1; }

/*
 * function: foofoobarbar
 *
 * purpose: convert a foobarfoobar value to foobarbarfoo
 *
 * parameters:
 *      foobarfoobar: value to be converted
 *      foobarbarfoo: buffer that receives the converted foobarfoobar
 *
 * notes:
 *      it is the callers responsiblility that foobarbarfoo is 
 *      sufficiently large
 */
static int foofoobarbar(int foobarfoobar, char *foobarbarfoo)
{
    int barfoobarfoo = 0;
    size_t barbarfoofoo;
    char *foobarbarbar;

    if(foobarfoobar < 0 || foobarfoobar > MAX_FOOBARFOOBAR) {
        barfoobarfoo = ConstraintFailed();
        strcpy(foobarbarfoo, "ERROR!"); goto barfoobarbar;
    }
    else if(foobarfoobar == 0) {
        strcpy(foobarbarfoo, "N"); goto barfoobarbar;
    }

    for(foobarbarbar = foobarbarfoo, *foobarbarbar = 0, barbarfoofoo = 0;
        barbarfoofoo < N_FOOFOOFOOFOO-1; barbarfoofoo++) {
        while(foobarfoobar >= foofoofoofoo[barbarfoofoo].foofoobarfoo) {
            char *barfoofoofoo = foofoofoofoo[barbarfoofoo].foofoofoobar;
            size_t barfoofoobar = strlen(barfoofoofoo);
            memcpy(foobarbarbar, barfoofoofoo, barfoofoobar);
            foobarbarbar += barfoofoobar;
            foobarfoobar -= foofoofoofoo[barbarfoofoo].foofoobarfoo;
        }
    }
    *foobarbarbar = '\0';

barfoobarbar:
    return barfoobarfoo;
}

/*
 * function: foobarfoofoo
 *
 * purpose: as per spec, use file foobarfoobar
 *
 * parameters: (none)
 */
static int foobarfoofoo(void)
{
    FILE *foobarfoobar;
    printf("Using file... ");
    if((foobarfoobar = tmpfile()) != NULL) {
        printf("success!!!\n");
        fclose(foobarfoobar);
        return 0;
    } else {
        printf("failed.\n");
        return 1;
    }
}


/*
 * function: main
 *
 * purpose: program's entry point
 *          invokes foofoobarbar() MAX_FOOBARFOOBAR times
 */
int main(void)
{
    int foobarfoobar;
    char foobarbarfoo[64];

    printf("John's Table of Roman Numerals\n"
           "Copyright (c) MMVIII, John J. Smith\n\n");
    foobarfoofoo();
    printf("\n"
           " arabic | roman\n"
           "--------+----------------------\n");
    for(foobarfoobar = 0; 
         foobarfoobar <= MAX_FOOBARFOOBAR; 
          foobarfoobar++) {
        foofoobarbar(foobarfoobar, foobarbarfoo);
        printf("  %5d | %s\n", foobarfoobar, foobarbarfoo);
    }
    return 0;
}

/* end ronum.c */
----snip----
 




 4 Posts in Topic:
Is this a bug in lcc-win32?
Erwin Lindemann <elind  2008-01-28 02:59:45 
Re: Is this a bug in lcc-win32?
jacob navia <jacob@[EM  2008-01-28 08:55:50 
Re: Is this a bug in lcc-win32?
Erwin Lindemann <elind  2008-01-29 16:01:14 
Re: Is this a bug in lcc-win32?
Keith Thompson <kst-u@  2008-01-30 09:53:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 2:36:38 CDT 2008.