Peter N Lewis wrote:
In MW Pascal, if a parameter is not used, then it can generate a warning, which you can silence with
{$unused( param_name )}
However GPC barfs when it sees this.
I believe the GPC way to silence the warning is to use attribute(unused), but then I also believe GPC does not currently catch this particular case.
I'm trying to ensure by source code both
a) compiles cleanly without any warnings and b) compiles under both GPC and MW Pascal
One portable way, BTW, is to use a local dummy variable and assign to it (in case of strings, e.g., you might want to assign its `Length' to a dummy integer, to avoid a possible string copy). This makes the parameter to be used, and a good optimizer should eliminate the dummy variable and the assignment.
Unfortunately, while I could probably define a macro like:
{$ifdef __GPC__} {$definec NOTUSED attribute(unused)} {$elsec} {$definec NOTUSED } {$endc}
and add the NOTUSED entries to my parameters, I cannot think of any way to get GPC to ignore or udnerstand the {$unused( param_name )}
Could $unused either be supported to disable the warning for a variable/parameter, or could we get some sort of flag to allow {$unused(x,y,z)} to be silently ignored so that it is possible to write code that is source compatible?
I don't really like this syntax, because (our) compiler directives usually don't refer directly to language elements (identifiers).
So I'd rather tend to ignore it -- perhaps ignore `{$unused...}' in Mac mode with a warning otherwise (or only if `-pedantic'?), just like we ignore several BP directives?
Frank