Sign in Join

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

Mailing lists / fpc-pascal / 2003-02

Macros in FPC

7 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Iván Montes

Hi,

I was wondering if I could do something like this with a macro in FPC:

const HASH_TABLE_MASK = $ff;
function GetHashIndex ( hash :dword) :integer;
begin
   result := hash AND HASH_TABLE_MASK;
end;

it's kind of a helper funcion so I don't want to perform the function call in the
code.
Would the inline modifier make it work without making a function call in the generated code?

TIA,
Ivan

Preben Mikael Bohn
to Gene Buckle

Hi Gene, have a look at http://www.freepascal.org/packages/mysql.html

It should be included in your FPC, I think...

Best regards Preben

Gene Buckle mumbled something about:

Show quoted text 12 lines
Can someone point me to some example code that shows access to MySQL via FPC? tnx. g. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
"I can think of no faster way to unite the American people behind George W. Bush than a terrorist attack on an American target overseas. And I believe George W. Bush will quickly unite the American people through his foreign policy." ~ Henry A. Kissinger
Anton Tichawa
to Iván Montes: I was wondering if I could do something like this with a macro in FPC: const…

Hello!

Show quoted text 15 lines
Hi, I was wondering if I could do something like this with a macro in FPC: const HASH_TABLE_MASK = $ff; function GetHashIndex ( hash :dword) :integer; begin result := hash AND HASH_TABLE_MASK; end; it's kind of a helper funcion so I don't want to perform the function call in the code. Would the inline modifier make it work without making a function call in the generated code?

If your goal is performance, i. e. to include the function's body in your code without call and return, simply use the inline feature. I cite the documentation:

<cite>

4 inline

Procedures that are declared inline are copied to the places where they are called. This has the effect that there is no actual procedure call, the code of the procedure is just copied to where the procedure is needed, this results in faster execution speed if the function or procedure is used a lot.

By default, inline procedures are not allowed. Inline code must be enabled using the command-line switch -Si or {$inline on} directive.

Inline code is NOT exported from a unit. This means that when calling an inline procedure from another unit, a normal procedure call will be performed. Only inside units, Inline procedures are really inlined. Recursive inline functions are not allowed. i.e. an inline function that calls itself is not allowed.

</cite>

E. g.

function satured_square(n: integer; max: integer): integer; inline;

Every "call" to saturated_square within the same unit will be inlined.

HTH

Anton Tichawa.

----------

"Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte Berechnungen einzuweben."

Doris Langley Moore: Ada, Countess of Lovelace (London 1977).

----------

Anton Tichawa
Volkertstrasse 19 / 20
A-1020 Wien
mobil: +43 664 52 07 907
email:

----------

Anton Tichawa
to Gene Buckle: Can someone point me to some example code that shows access to MySQL via FPC? tnx. g.
you wrote
Can someone point me to some example code that shows access to MySQL via

http://www.freepascal.org/contrib/db.php3?category=Database

---------- "Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte Berechnungen einzuweben." Doris Langley Moore: Ada, Countess of Lovelace (London 1977). ---------- Anton Tichawa Volkertstrasse 19 / 20 A-1020 Wien mobil: +43 664 52 07 907 email: ----------
Gene Buckle
to Anton Tichawa

Thanks - I've got that installed already.

g.

Anton Tichawa wrote 27 lines
On Monday 10 February 2003 19:47, you wrote: > Can someone point me to some example code that shows access to MySQL via http://www.freepascal.org/contrib/db.php3?category=Database -- ---------- "Adas Methode war, wie sich zeigen wird, Tagtr�ume in offenbar korrekte Berechnungen einzuweben." Doris Langley Moore: Ada, Countess of Lovelace (London 1977). ---------- Anton Tichawa Volkertstrasse 19 / 20 A-1020 Wien mobil: +43 664 52 07 907 email: ---------- _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal