Sign in Join

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

Mailing lists / fpc-devel / 2025-03

Error: Procedure/Function declared with call option NOSTACKFRAME but without ASSEMBLER

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Martin Frb
It is possible to declare a type for a cdecl function like
type  a=procedure cdecl;

But, not for "assembler" which makes sense, because its not a calling convention. Same should likely be the case for NoStackframe.

But

program Project1;
type  a=procedure {assembler} NoStackFrame ;
begin
end.

gives a different error?
Should it?

Reply by email

Marco van de Voort
to Martin Frb

Op 20-3-2025 om 20:09 schreef Martin Frb via fpc-devel:

Show quoted text 5 lines
It is possible to declare a type for a cdecl function like type  a=procedure cdecl; But, not for "assembler" which makes sense, because its not a calling convention. Same should likely be the case for NoStackframe.

Roughly yes. Basically a procedure variable is a contract which should give the calling situation enough information to call the said function.

Show quoted text 7 lines
But program Project1; type  a=procedure {assembler} NoStackFrame ; begin end.

assembler is a comment?

gives a different error?

Which error do you mean? Not to be facetious, just that errors might depend on architecture.

Should it?

The bar is twofold, the first, as said,  being that the calling side must have enough information to call the result in all circumstances (read: on all targets), and the second , minor one, if that if there is an exception for parameterless functions, if it is worth to implement an exception.

Reply by email

Martin Frb
to Marco van de Voort

Ok, maybe I lost the point in verbosity.

The following type
   type  a=procedure foo;
gives the error
    project1.lpr(2,19) Fatal: Syntax error, ";" expected but "identifier FOO" found

In a type declaration, the procedure can not have a name, and "foo" is not a valid modifier here (cdecl would be and can be given).

But then
    type  a=procedure NoStackFrame ;
gives
   project1.lpr(3,1) Error: Procedure/Function declared with call option NOSTACKFRAME but without ASSEMBLER

Though I can not specify
    type  a=procedure assembler;
because it also gives
   project1.lpr(7,33) Fatal: Syntax error, ";" expected but "identifier ASSEMBLER" found

I.e. assembler seems not to be relevant for the type declaration. It can only be given when I actually declare a procedure.

It also wont work as
     type  a=procedure assembler NoStackFrame ;
     type  a=procedure NoStackFrame assembler;

So why does the compiler interpret NoStackFrame in the type declaration, when it does not do that for other non-relevant modifiers (like assembler)?

Just curious...

Marco van de Voort wrote 40 lines
Op 20-3-2025 om 20:09 schreef Martin Frb via fpc-devel: > It is possible to declare a type for a cdecl function like > type  a=procedure cdecl; > > But, not for "assembler" which makes sense, because its not a calling > convention. Same should likely be the case for NoStackframe. Roughly yes. Basically a procedure variable is a contract which should give the calling situation enough information to call the said function. > But > > program Project1; > type  a=procedure {assembler} NoStackFrame ; > begin > end. > assembler is a comment? > gives a different error? Which error do you mean? Not to be facetious, just that errors might depend on architecture. > Should it? > The bar is twofold, the first, as said,  being that the calling side must have enough information to call the result in all circumstances (read: on all targets), and the second , minor one, if that if there is an exception for parameterless functions, if it is worth to implement an exception. _______________________________________________ fpc-devel maillist  -  https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Marco van de Voort
to Martin Frb

Op 20-3-2025 om 20:46 schreef Martin Frb via fpc-devel:

So why does the compiler interpret NoStackFrame in the type declaration, when it does not do that for other non-relevant modifiers (like assembler)?

I think it is because nostackframe is a directive for the declaration of the function itself, to tell the stackframe generating code to skip the stackframe. That is also why it is linked to assembler; directive, since with assembler the compiler can't auto determine to generate a stack frame.

It has no relevance to the calling code, so it has no business in a procedural type declaration.

Maybe take a step back and try to describe what you want to achieve.

Reply by email

Martin Frb
to Marco van de Voort
Marco van de Voort wrote 17 lines
Op 20-3-2025 om 20:46 schreef Martin Frb via fpc-devel: > So why does the compiler interpret NoStackFrame in the type > declaration, when it does not do that for other non-relevant > modifiers (like assembler)? I think it is because nostackframe is a directive for the declaration of the function itself, to tell the stackframe generating code to skip the stackframe. That is also why it is linked to assembler; directive, since with assembler the compiler can't auto determine to generate a stack frame. It has no relevance to the calling code, so it has no business in a procedural type declaration. Maybe take a step back and try to describe what you want to achieve.

Nothing, I just stumbled on it. And wondered.

I know errors aren't necessarily always describing what a user would see as the error. But in this case, the compiler says that the error is the omission of another error. That is a novum. (well for me at least).

Reply by email