Already later than I thought

Posted by ALB42 on 26. Juli 20113 Comments

I got a new interesting bug report… about non working Now() function it always gives the same date and time (something 2112 , wow so later already i missed some time seems).

I was astonished that the same routine like the one now() uses to gather the time works when I directly type in into my Code.. so the error ONLY exists inside the RTL – unit

This bug was very hard to find, seems everything was ok.. just the DoIO for the timer.device returns with IOERR_NOCMD which means the timer.device does not support getting of date/time… really strange… i tried out some thing an noticed it already is strange before when create the timer (which i need to get the time).. the Base Pointer for the timer device was always NIL.

Then finally i got the right idea… I compared the structures for  the aros units and for the rtl.. they looks equal BUT there was a tiny difference… the records for the rtl (which doesn’t work) were defined as PACKED record… in aros unit (which works) just as record, means aligned, VERY strange hmm even for Amiga this would meet a problem? Now I changed everything to aligned records and it works…. sometimes easy errors so hard to find.

3 comments to "Already later than I thought"

  1. 1) Don’t add packed. Set alignment globally with $packrecords.

    2) on the aros forum I saw something about dual inclusion of .inc files. It is allowed to have platform specific units in the RTL (though if it is 10MB+ it is better to separate the headers into the needed parts in the RTL and a separate package for the rest)

    Don’t forget to drop by irc.freenode.net #fpc and #lazarus-ide from time to time.

  2. marcus sagt:

    The packed was not added by me….it came by the copy from Amiga rtl

    platform specific was not the problem… but the question is its allowed that a Package use an include from RTL directory? ….. or even worse… RTL use an include in a package directory?

  3. An include is not allowed of course. But you can simply stuff it in a platform specific unit, and then alias the types.

    So assume you have identifiers A, B, C, D, E, and only A..C are needed in the RTL.

    The typical trick is:
    * make an include file in the RTL.
    * use the include file in the *implementation* of system if needed.
    * create a new unit (for the RTL), say arosbase, and import the include, and any other AROS specific stuff.
    * the rest of the RTL (sysutils etc) imports this unit.

    Now say that in packages/ you want to have more extensive headers. Have an unit, say arosfull, and have it look like:

    unit arosfull;

    interface

    uses arosbase;

    type
    a= arosbase.a;
    b= arosbase.b;
    c= arosbase.c;

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.