Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is this a bug in lcc-win32?

1 view
Skip to first unread message

Erwin Lindemann

unread,
Jan 27, 2008, 8:59:45 PM1/27/08
to

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 documentation 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 supporting documentation.
*
*/

/*
* 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----

jacob navia

unread,
Jan 28, 2008, 2:55:50 AM1/28/08
to
Erwin Lindemann wrote:
> 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----
>
1) Read the error message.
2) Read the documentation about the safe C library
3) Use another compiler. As I told you in comp.lang.c gcc is the best


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32

Erwin Lindemann

unread,
Jan 29, 2008, 10:01:14 AM1/29/08
to
jacob navia wrote:

> Erwin Lindemann wrote:
>> 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----
>>
> 1) Read the error message.
> 2) Read the documentation about the safe C library
> 3) Use another compiler. As I told you in comp.lang.c gcc is the best

Jacob,

thanks for the quick reply. I'm sure the information contained therein
is very useful, for people with deep enough technical background, but
unfortunately it is not for me. Could you please clarify?

Many thanks,
Erwin Lindemann

Keith Thompson

unread,
Jan 30, 2008, 12:53:14 PM1/30/08
to
jacob navia <ja...@nospam.com> writes:
> Erwin Lindemann wrote:
>> 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----
>>
> 1) Read the error message.
> 2) Read the documentation about the safe C library
> 3) Use another compiler. As I told you in comp.lang.c gcc is the best

Is this "safe C library" something specific to lcc-win, or is it from
some outside source? (n1135.pdf is TR 24731, a draft "Specification
for Safer, More Secure C Library Functions", but that document doesn't
mention "safelib.h" or "ConstraintFailed".)

Is there a way to disable this "safe C library", so that a user
program can use the identifier "ConstraintFailed" for its own
purposes?

Can you clarify your third point above? Was it merely sarcastic, or
was there some deeper point?

Is this how you usually deal with bug reports from your users?

--
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"

0 new messages