Lazarus

Free Pascal => Beginners => Topic started by: Weiss on July 04, 2022, 09:52:48 am

Title: Inline code does not compile?
Post by: Weiss on July 04, 2022, 09:52:48 am
I am studying by "Turbo Pascal 6 Complete Reference Guide". The part where it describes using inline code does not compile. Sometimes  the  "inline" identifier is not recognized.  Most of the time Compiler sees "(" where it wants ":". I tried using compiler directives {$mode TP} and {$INLINE+} or {$INLINE ON} but syntax error is still there.

What is the trick here? How do we use inline code in FPC, that is different from what was in TP?
Title: Re: Inline code does not compile?
Post by: MarkMLl on July 04, 2022, 10:55:21 am
SHOW US YOUR CODE!!!!!!!!!!!!

If it's a small program it's OK to put it inline with your message but you will need to mark it with the code tag. Otherwise add it as an attachment. In either case please make sure that it's a complete program, i.e. something that other people can fairly be expected to compile without spending lots of time working out what you're trying to do.

Apart from that, what version of FPC etc. are you using?

Note also that in some cases the FPC compiler will compile something without obeying an inline directive (due to code complexity etc.); you will get a warning if this happens.

MarkMLl
Title: Re: Inline code does not compile?
Post by: marcov on July 04, 2022, 11:23:47 am
The inline command (with bytes to inline assembler) of Turbo Pascal is not supported yet. (though I can vaguely recall Nikolay adding it to trunk).

But even then it is  16-bits dos only, and I'm not sure you want that, so in practice you will need to find other solutions anyway.

Examples would help, and also what your goal is (really dos?  16-bit or 32-bit ?)
Title: Re: Inline code does not compile?
Post by: Zvoni on July 04, 2022, 11:30:20 am
Apart from that, what version of FPC etc. are you using?
LOL. What did we discuss in that other thread of yours?
Title: Re: Inline code does not compile?
Post by: 440bx on July 04, 2022, 11:31:13 am
I am studying by "Turbo Pascal 6 Complete Reference Guide". The part where it describes using inline code does not compile. Sometimes  the  "inline" identifier is not recognized. 
The old TP inline thing where the programmer had to hand code the bytes for opcodes and data is really extremely undesirable.

With FPC, you can code that inline stuff in assembler.  I remember that, at least most of the time, programmers were courteous enough to put the equivalent assembly statements next to the hand coded bytes as a comment thus, making the "port" to real assembler fairly straightforward.

My recommendation is: stay as far away from that old inline stuff and, if needed, convert it to assembler.

Title: Re: Inline code does not compile?
Post by: PascalDragon on July 04, 2022, 01:20:18 pm
The inline command (with bytes to inline assembler) of Turbo Pascal is not supported yet. (though I can vaguely recall Nikolay adding it to trunk).

Trunk supports the Inline statement in mode TP on any platform (and it was added by Yuriy, not Nikolay ;) ).

Though for new code I definitely suggest to use an asmend-block as one doesn't need to fiddle around with hex dumps then.
Title: Re: Inline code does not compile?
Post by: Weiss on July 05, 2022, 01:08:10 pm
Thank you for all replies, fellas.

seems like a great crowd here.. Anyways, I am re-writing inline snippets in assembler now. Like 440bx suspected, there are asm equivalents commented on each line.

There is no point posting the code, I was typing examples from that book, interrupts etc.

By the way, assembler is fun in its own right.
Title: Re: Inline code does not compile?
Post by: MarkMLl on July 05, 2022, 02:19:58 pm
seems like a great crowd here.. Anyways, I am re-writing inline snippets in assembler now. Like 440bx suspected, there are asm equivalents commented on each line.

My apologies that I misinterpreted your initial posting: since you didn't specify assembler I assumed you'd found some odd case associated with the inline modifier which can be applied to functions etc.

MarkMLl
Title: Re: Inline code does not compile?
Post by: PascalDragon on July 05, 2022, 02:25:20 pm
seems like a great crowd here.. Anyways, I am re-writing inline snippets in assembler now. Like 440bx suspected, there are asm equivalents commented on each line.

My apologies that I misinterpreted your initial posting: since you didn't specify assembler I assumed you'd found some odd case associated with the inline modifier which can be applied to functions etc.

Weiss mentioned Turbo Pascal 6 which does not know the inline modifier, so it was clear without him mentioning assembly code. ;)
TinyPortal © 2005-2018