On the internet I found a small unit to calculate CRC32 values, which I
need for a small project.
However, when I include this unit in my project, I suddenly get a lot of
warnings like the following:
[DCC Warning] Crc32.pas(15): W1012 Constant expression violates subrange
bounds
I've had a look around on the net on several forums, and they all seem to
offer solutions on how to change the code, so the warning doesn't appear at
all. However, I'm not inclined to change the unit (as I don't want to mess
with all those declared constants), so I'd like to know if there is a way
to turn off the warnings for this particular unit.
Is there perhaps a compiler directive of sorts that lets me ignore these
warnings?
A link to a unit, calculating CRC32 values, without warnings is of course
also very welcome :)
Thanks,
Ikke
It's that CONST Array that rises those messages. In my oldish CRC.PAS
the Array is implemented this way:
CONST
table: ARRAY[0..255] OF LongInt =
($00000000, $77073096, $EE0E612C, $990951BA,
$076DC419, $706AF48F, $E963A535, $9E6495A3,
etc...
I have used that Unit at least 6 years this way, and it always
calculates CRS's fine. But its is true that the compiler show those
error messages.
You could change the typing this way and make those error messages to go
away:
table: ARRAY[0..255] OF LongWord =
I can see that I have changed LongInt --> LongWord in 2004. But I can
also see that I have changed it back some weeks later. I do not recall
if there were any complications or why I actually did turn it back to
LongInt.
> A link to a unit, calculating CRC32 values, without warnings is of course
> also very welcome :)
I also thought in 2004 that that those error messages are no good for a
decent programmer. And did those tests with Typing changes and tried to
look another CRC units etc.
My memory does not serve me so well that I could remember what kind of
replacements I found. And also why I finally turned back to this good
and rock solid unit, and decided to forget those error messages.
Peter
The compiler directive is the $WARNINGS.
e.g.: {$WARNINGS OFF} or {$WARNINGS ON}
But this directive is one of those that can't be specified via
command-line parameter.
The warning itself is just well... a warning message. Inserting a
{$WARNINGS OFF} at the ssstart of the IMPLEMENTATION block of CRC32.PAS
will only change the source code. There would be no difference on the
compiled unit code regardless of the compiler directive presence.
Other method to silence warning messages in a unit is to put the
compiler directive in the main project's CFG file. e.g.: if your
application project file is CrcCalc.dpr, then the project configuration
file would be CrcCalc.cfg. You can also put the compiler directive in
the DCC32.CFG file. But modifying the CFG file will make the compiler
directive as the default settings and it will affect more than one units
being compiled.
<snip>
> The compiler directive is the $WARNINGS.
> e.g.: {$WARNINGS OFF} or {$WARNINGS ON}
Thanks Jaelani, that's what I was looking for.
> But this directive is one of those that can't be specified via
> command-line parameter.
>
> The warning itself is just well... a warning message. Inserting a
> {$WARNINGS OFF} at the ssstart of the IMPLEMENTATION block of
> CRC32.PAS will only change the source code. There would be no
> difference on the compiled unit code regardless of the compiler
> directive presence.
Good - I only want to get rid of those messages while compiling/building.
As Peter already pointed out, he's been fiddling with the unit as well,
and as far as I can tell the unit works great. So I just want to get rid
of the messages, without touching the code itself. Silencing these
warnings is enough to do that :)
Thanks again!
Best regards,
Ikke
const
CRC32Table:array [0..255] of longword=
($00000000,$77073096,$EE0E612C,$990951BA,$076DC419,$706AF48F,$E963A535,$9E6495A3,
...
and I get no warnings.
--
Dale