Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-01

{$calling register} compiler-directive at wrong place (bug 12881)

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Joost van der Sluis

Hi all,

In the fftw package the {$calling cdecl} directive is at the top of the file, and {$calling register} is somewhere in the interface section.

Now the problem seems to be that the function defined directly before the {$calling register} directive is already defined as register.

This code: (from packages/fftw/fftw_s.pas)

{$calling cdecl}
...
procedure fftw_execute(plan:fftw_plan_single);
          external 'fftw3f' name 'fftwf_execute'; // <-- register
{$calling register}

The procedure fftw_execute is called by the example (fftw/examples) as being register. If you place another function in between the declaration and the compiler-directive, it is cdecl:

{$calling cdecl}
...
procedure fftw_execute(plan:fftw_plan_single);
          external 'fftw3f' name 'fftwf_execute'; // <-- cdecl
function
fftw_plan_dft(rank:cardinal;n:Pcardinal;i:Pcomplex_single;o:Psingle;
                       flags:fftw_flagset):fftw_plan_single;
         external 'fftw3f' name 'fftwf_plan_dft_c2r';
{$calling register}

How can that happen?

Joost

Reply by email

Daniël Mantione
to Joost van der Sluis

Op Sun, 11 Jan 2009, schreef Joost van der Sluis:

Show quoted text 7 lines
{$calling cdecl} ... procedure fftw_execute(plan:fftw_plan_single); external 'fftw3f' name 'fftwf_execute'; // <-- register {$calling register} How can that happen?

It may have to do something with the proceduren not being processed immedeatelym, after which the preprocessor may have already set the calling convention to register. It sounds like a serious bug.

Daniël

Reply by email

Jonas Maebe
to Joost van der Sluis: In the fftw package the {$calling cdecl} directive is at the top of the file, and…
Joost van der Sluis wrote
Now the problem seems to be that the function defined directly before the {$calling register} directive is already defined as register.

Many bugs like that have been fixed in the scanner in the past. There are workarounds to prevent this sort of stuff from happening for all the checks directives ({$r+/-}, {$i+/-}, {$q+/-}, ...), for {$push}/ {$pop}, etc... Basically such changes have to be cached when processed and flushed later.

Please file a bug report.

Jonas

Reply by email