Compiler mode for code in rtl and rtl-extra

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiler mode for code in rtl and rtl-extra

Free Pascal - General mailing list
I've been beavering away at a fix for
https://bugs.freepascal.org/view.php?id=37013 and I've run into
something unexpected. When I try to build rtl-extra with my proposed
patch applied, I get compiler errors for things like the use of result
variables and var/out variables. I'm so used to these being available
that I quite forgot there are modes where they're not.

My question is, first, what mode is the compiler using, and second, is
this required for portability to other platforms?

Or am I completely misunderstanding this?

Example error messages:
sockets.inc(497,5) Error: Identifier not found "Result"

sockets.inc(510,53) Fatal: Syntax error, ":" expected but "identifier
RES" found

for this definition:

   function convert_hextet(const s: ShortString; out res: Word): Boolean;

It's not a big deal to rewrite around these, but first I want to make
sure I am correctly diagnosing the issue.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiler mode for code in rtl and rtl-extra

Michael Van Canneyt


On Mon, 11 May 2020, Noel Duffy via fpc-pascal wrote:

> I've been beavering away at a fix for
> https://bugs.freepascal.org/view.php?id=37013 and I've run into
> something unexpected. When I try to build rtl-extra with my proposed
> patch applied, I get compiler errors for things like the use of result
> variables and var/out variables. I'm so used to these being available
> that I quite forgot there are modes where they're not.
>
> My question is, first, what mode is the compiler using, and second, is
> this required for portability to other platforms?

The compiler uses fpc mode.

> Or am I completely misunderstanding this?
>
> Example error messages:
> sockets.inc(497,5) Error: Identifier not found "Result"
>
> sockets.inc(510,53) Fatal: Syntax error, ":" expected but "identifier
> RES" found
>
> for this definition:
>
>   function convert_hextet(const s: ShortString; out res: Word): Boolean;
>
> It's not a big deal to rewrite around these, but first I want to make
> sure I am correctly diagnosing the issue.

You are correct. The unit is compiled in fpc mode, which means no "result"
variable, no out param (replace with var).

We can envision changing this mode, but then the whole unit needs to be
verified and checked for correct functioning,
since it will redefine basic types as integer from 16 to 32 bit, change the meaning of string.

I don't think you will want to undertake that effort :)

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiler mode for code in rtl and rtl-extra

Free Pascal - General mailing list
On 11/05/20 7:29 pm, Michael Van Canneyt wrote:
>
> On Mon, 11 May 2020, Noel Duffy via fpc-pascal wrote:

>> Example error messages:
>> sockets.inc(497,5) Error: Identifier not found "Result"
>>
>> sockets.inc(510,53) Fatal: Syntax error, ":" expected but "identifier
>> RES" found
>>
>> for this definition:
>>
>>   function convert_hextet(const s: ShortString; out res: Word): Boolean;
>
> You are correct. The unit is compiled in fpc mode, which means no "result"
> variable, no out param (replace with var).

Great. If var is available then the job is easy.

> We can envision changing this mode, but then the whole unit needs to be
> verified and checked for correct functioning, since it will redefine
> basic types as integer from 16 to 32 bit, change the meaning of string.
>
> I don't think you will want to undertake that effort :)

I don't think I want to do it either! This certainly falls under the "If
it ain't broke" maxim.

Thanks for the fast response.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Compiler mode for code in rtl and rtl-extra

Free Pascal - General mailing list
In reply to this post by Michael Van Canneyt
On Mon, May 11, 2020 at 9:30 AM Michael Van Canneyt
<[hidden email]> wrote:

> You are correct. The unit is compiled in fpc mode, which means no "result"
> variable, no out param (replace with var).
>
> We can envision changing this mode, but then the whole unit needs to be
> verified and checked for correct functioning,

Maybe one could apply {$modeswitch out} ?


--
Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal