[Fixed] Porting AmiDARK Engine to MorphOS. Compilation Error
  • Caterpillar
    Caterpillar
    AmiDARK
    Posts: 38 from 2011/10/29
    From: South France
    Hello,

    I'm new here and, actually, I'm porting the actual build of my AmiDARK Engine GDK from AmigaOS4.1 to MorphOS and I encounter small compilation issues I don't find solution.

    I include file : #include <devices/timer.h> that contain "timeval" structure.

    I create my own copy this way :
    struct timeval * MyTimeVal;
    ULONG NewTimer;

    I use the OS function :
    GetSysTime( MyTimeVal );

    When I compile, I obtain 2 times the same error to this line :
    NewTimer = ( MyTimeVal->tv_secs * (ULONG)1000000 ) + MyTimeVal->tv_micro;

    Error : "dereferencine pointer to incomplete type"...

    However, I use the correct struct and data types ... Does someone have any clue ?

    Thank you.
    @ +
    AmiDARK

    [ Edité par AmiDARK 29.10.2011 - 19:45 ]
  • »29.10.11 - 15:34
    Profile Visit Website
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    Seems that there is another problem. GetSysTime fills a timeval structure, adress of which is passed as argument. But you have only a pointer defined, not a structure. So unless MyTimeVal is initialized before, a random pointer is accessed. I would do it as follows:

    Code:
    struct timeval MyTimeVal;

    GetSysTime(&MyTimeVal);
    NewTimer = MyTimeVal.tv_secs * 1000000 + MyTimeVal.tv_micro;


    About this "deferencing pointer to incomplete type" is hard to say anything not having the complete source file.
  • »29.10.11 - 16:49
    Profile Visit Website
  • Caterpillar
    Caterpillar
    AmiDARK
    Posts: 38 from 2011/10/29
    From: South France
    Hi Krashan :)
    And thank you for your reply.

    Here is more concerning this code ( I cannot copy the full source as it is too long ... )
    I've modified my source with your informations and it didn't worked too.

    Includes :
    #include <time.h>
    #include <devices/timer.h>
    #include <proto/timer.h>
    (others includes included but not related to timer.device, so I don't add them here)

    Definition :
    long OldTimer;
    long NewTimer;
    struct timeval MyTimeValReal;
    struct timeval * MyTimeVal = &MyTimeValReal;

    API Call to get informations about actual timer :
    GetSysTime( &MyTimeValReal );

    Calculation for timer delays :
    NewTimer = ( MyTimeVal->tv_secs * (long)1000000 ) + MyTimeVal->tv_micro;
    ( I always get the error "dereferencing pointer to incomplete type", 2 times on this line.

    but I also get an error saying :
    storage size of 'MyTimeValReal' isn't known

    Have I forgotten files to include ?

    EDIT : When I modify with what you said, I get error "invalid use of undefined type 'struct timeval' ...

    Kindest Regards,
    AmiDARK


    [ Edité par AmiDARK 29.10.2011 - 19:22 ]

    [ Edité par AmiDARK 29.10.2011 - 19:31 ]

    [ Edité par AmiDARK 29.10.2011 - 19:31 ]
  • »29.10.11 - 17:34
    Profile Visit Website
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    Code:

    Ram Disk:> type test.c
    #include <time.h>
    #include <devices/timer.h>
    #include <proto/timer.h>

    long OldTimer;
    long NewTimer;
    struct timeval MyTimeValReal;
    struct timeval * MyTimeVal = &MyTimeValReal;

    int main(void)
    {
    GetSysTime( &MyTimeValReal );

    NewTimer = ( MyTimeVal->tv_secs * (long)1000000 ) + MyTimeVal->tv_micro;

    return 0;
    }
    Ram Disk:> gcc -noixemul -Wall test.c
    Ram Disk:>

    So I would say maybe the rest of the source is important in this case...
  • »29.10.11 - 18:26
    Profile Visit Website
  • Caterpillar
    Caterpillar
    AmiDARK
    Posts: 38 from 2011/10/29
    From: South France
    Hi Henes.
    I have fixed my issue by adding the original timeval structure definition in my file... Now I have no more error message concerning this structure and the use I do with it but I have another more complet issue ...

    But now the error message is really strange:

    s:\local\amiga\ppc-morphos\lib\crt0.o in function 'exec_entry'
    [Linker Error] undefined reference to `__stk_argbytes'
    [Linker Error] undefined reference to `__stk_argbytes'
    [Linker Error] undefined reference to `__stk_limit'
    [Linker Error] undefined reference to `__stk_limit'
    [Linker Error] undefined reference to `__init_stk_limit'
    And same on other functions like : 'ENTRY', 'ix_get_variables', etc ...

    What do that kind of errors may say ?
    PS : I use AmiDevCPP on a PC Computer for cross compiling.

    EDIT :
    Now Fixed ..
    The only errors I have are "undefined reference to '...'.
    I think I can fix them :p

    Kindest Regards,
    AmiDARK

    [ Edité par AmiDARK 29.10.2011 - 19:40 ]

    [ Edité par AmiDARK 29.10.2011 - 19:45 ]
  • »29.10.11 - 18:35
    Profile Visit Website
  • MorphOS Developer
    Henes
    Posts: 507 from 2003/6/14
    By locally redefining struct timeval, you are only hiding the real problem.

    The undefinined symbols must be caused by a missing -noixemul argument given to gcc when compiling.
    See the "ix" symbol... this is really hinting you are compiling for ixemul instead of libnix.

    Remember the -noixemul argument must be given to GCC both when compiling AND when linking.
    Otherwise the wrong set of headers (at compile time) and static libraries (at link stage) is used.
    Actually, the timeval issue could be related too.


    [ Edited by Henes 29.10.2011 - 20:06 ]
  • »29.10.11 - 19:05
    Profile Visit Website
  • Caterpillar
    Caterpillar
    AmiDARK
    Posts: 38 from 2011/10/29
    From: South France
    Yes, in fact, the files for timer.device were included in the main project file.
    I have added the 3 timer.device files to include directly in the file where the errors were and now, no more compilation issue concerning timer.device functions and uses ...
    the ix ... exec ... errors were related to an error in the makefile configuration that did link to AmigaOS4 includes files instead of MorphOS ones ... Fixed this too :)

    Now, I continue fixing other migration issue :p

    Thank you all.

    Kindest Regards,
    AmiDARK
  • »29.10.11 - 19:15
    Profile Visit Website