Aborting compilation

Pascal Viandier pviandie at accovia.com
Thu Apr 30 21:24:47 CEST 2009


Hi Frank,

> 
> Pascal Viandier wrote:
> 
> > Is there a gpc directive that can issue a message and then abort the
> > compilation?
> > I tried {$M ...} but it does not stop the compilation process.
> >
> > My goal is to prohibit the use of FillChar() in our code by stopping
the
> > compilation when the compiler finds one.
> 
> {$error foo}
> 
> The compilation will continue, like after most errors, but return
> with an error at the end. However, the above does not work as a
> macro such as "{$define foo {$error foo}}" since nested compiler
> directives are not (yet) allowed.
> 

Too bad :-(

> > I used a macro that redefines FillChar(a,b,c); as {$M ERROR:
Fillchar
> > use is not allowed!} but this does not seem sufficient to prevent
its
> > usage and its destructive effect on strings :-(
> 
> Destructive only if used carelessly. When used in a proper way
> (possibly the only one originally intended), it's fine:
> 
> FillChar (s[a], b, c);  { provided (a >= 1) and (a + b - 1 <= Length
(s)) }
> 
> (It's destructive if you do "FillChar (s, ...)". But even with BP
> strings that's usually at least pointless, since the first "char" is
> the length byte. If you fill with 0, you set the length to 0, and so
> the string to '', but you get the same thing more efficiently (even
> in BP) and much more portably by just doing "s := ''". Unless in
> very special circumstances where you also need all characters to be
> Chr(0), such as perhaps when you want to write the string to a
> binary file and be sure it contains no dummy data.)
> 

I agree but the problem is we have more than 600 modules and some
developers continue to use FillChar liberally on records that contain
strings so the problems appear only at execution time. That's why I want
to use a final solution.

> > If there is no such compiler directive, any other suggestion is
welcome.
> 
> {$disable-predefined-identifier=FillChar}

This is exactly what I was looking for.
It flags FillChar as an unknown symbol and prevents the generation of
the object.
That's perfect!

Thank you very much for the hint.

Pascal

> 
> Frank
> 
> --
> Frank Heckenbach, f.heckenbach at fh-soft.de, http://fjf.gnu.de/,
7977168E
> GPC To-Do list, latest features, fixed bugs:
> http://www.gnu-pascal.de/todo.html
> GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE  D101 CD02 4C9D
0FE0 E5E8






More information about the Gpc mailing list