Thread overview
problem with const keyword in casting
Oct 13, 2004
Benoit
Oct 14, 2004
Arjan Knepper
Oct 15, 2004
Benoit
Oct 18, 2004
Arjan Knepper
October 13, 2004
Hi,
I am trying to compile the watt-32 library with digital mars. I got only 4 files
that wasn't compiled by digital mars. I was unable to fix the compilation errror
and think now that it is an issue with de digital mars compiler.

Here is the error ouput of the first file:

c:\djgpp\bin\dmc -ml -a2 -I. -I..\inc -IC:\dm\include -W -fno-strength-reduce -f
fast-math  -o digmars/misc.o -c misc.c
misc.c:
((int(far *)(void const const *, void const const *))list_compare));
^
misc.c(463) : Error: need explicit cast for function parameter 4 to get
from: int (*far C func)(void *,void *)
to  : int (*far C func)(void const *,void const *)
--- errorlevel 1
make.exe: *** [digmars/misc.o] Error 1

C:\net\watt\src>

The cast is exactly as requested by the compiler. I try all sort of variation and I am unable to please digital mars. I feel that digital mars have some difficulty with the "const" keyword.

I got similar error with 3 other files.

Ex.: char const var instead of const char var
Ex.:
from: int (*far C func)(void *,void *)
to  : int (*far C func)(void const *,void const *)

the from: line is no having the const keywork but the cast into the line of C++ code is having the const keyword. That's why digitial mars see and not see the const keyword.

thank you

Benoit


October 14, 2004
Benoit wrote:
> c:\djgpp\bin\dmc -ml -a2 -I. -I..\inc -IC:\dm\include -W -fno-strength-reduce -f
> fast-math  -o digmars/misc.o -c misc.c
> misc.c:
> ((int(far *)(void const const *, void const const *))list_compare));
> ^
> misc.c(463) : Error: need explicit cast for function parameter 4 to get
> from: int (*far C func)(void *,void *)
> to  : int (*far C func)(void const *,void const *)
> --- errorlevel 1
> make.exe: *** [digmars/misc.o] Error 1

Can you post the lines 460-465 from misc.c? Because that is the code the compiler is complaining about.

Arjan
October 15, 2004
HI, the lines are:

qsort (&exit_list, DIM(exit_list), sizeof(exit_list[0]),
(int(*)(const void *, const void *))list_compare);

Benoit

In article <cklh3d$1tsl$1@digitaldaemon.com>, Arjan Knepper says...
>
>Benoit wrote:
>> c:\djgpp\bin\dmc -ml -a2 -I. -I..\inc -IC:\dm\include -W -fno-strength-reduce -f
>> fast-math  -o digmars/misc.o -c misc.c
>> misc.c:
>> ((int(far *)(void const const *, void const const *))list_compare));
>> ^
>> misc.c(463) : Error: need explicit cast for function parameter 4 to get
>> from: int (*far C func)(void *,void *)
>> to  : int (*far C func)(void const *,void const *)
>> --- errorlevel 1
>> make.exe: *** [digmars/misc.o] Error 1
>
>Can you post the lines 460-465 from misc.c? Because that is the code the compiler is complaining about.
>
>Arjan


October 18, 2004
Benoit wrote:
> HI, the lines are:
> 
> qsort (&exit_list, DIM(exit_list), sizeof(exit_list[0]),
> (int(*)(const void *, const void *))list_compare);
> 

I don't see why this would not work assuming the other function parameters are correct.

To work around this, you could try to wrap 'list_compare' in a function with the exact signature required by qsort.
e.g.

int  qsort_wrap ( const void  *_f, const void  *_s )
{
   return ( list_compare ( (cast) _f, (cast) _s ) );
}

Arjan

> Benoit
> 
> In article <cklh3d$1tsl$1@digitaldaemon.com>, Arjan Knepper says...
> 
>>Benoit wrote:
>>
>>>c:\djgpp\bin\dmc -ml -a2 -I. -I..\inc -IC:\dm\include -W -fno-strength-reduce -f
>>>fast-math  -o digmars/misc.o -c misc.c
>>>misc.c:
>>>((int(far *)(void const const *, void const const *))list_compare));
>>>^
>>>misc.c(463) : Error: need explicit cast for function parameter 4 to get
>>>from: int (*far C func)(void *,void *)
>>>to  : int (*far C func)(void const *,void const *)
>>>--- errorlevel 1
>>>make.exe: *** [digmars/misc.o] Error 1
>>
>>Can you post the lines 460-465 from misc.c? Because that is the code the compiler is complaining about.
>>
>>Arjan
> 
> 
>