• Re: A problem with HB_FUNC

    From Enrico Maria Giordano@21:1/5 to All on Tue Sep 19 12:04:57 2023
    Il 19/09/2023 12:03, Enrico Maria Giordano ha scritto:

    HB_FUNC( SCAVENGEAL )

    This function name is irrelevant. It errors out with any function name.

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Tue Sep 19 12:03:40 2023
    This sample works fine with Harbour but not with xHarbour. Ron, can you
    try to fix it, please?


    FUNCTION MAIN()

    RETURN NIL


    #pragma BEGINDUMP

    #ifdef __MYTEST__

    HB_FUNC( SCAVENGEAL )
    {
    }

    #endif

    #pragma ENDDUMP


    With xHarbour:

    error LNK2001: unresolved external symbol _HB_FUN_SCAVENGEAL

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ron Pinkas@21:1/5 to Enrico Maria Giordano on Tue Sep 19 16:02:42 2023
    On Tuesday, September 19, 2023 at 5:03:43 AM UTC-5, Enrico Maria Giordano wrote:
    This sample works fine with Harbour but not with xHarbour. Ron, can you
    try to fix it, please?


    FUNCTION MAIN()

    RETURN NIL


    #pragma BEGINDUMP

    #ifdef __MYTEST__

    HB_FUNC( SCAVENGEAL )
    {
    }

    #endif

    #pragma ENDDUMP


    With xHarbour:

    error LNK2001: unresolved external symbol _HB_FUN_SCAVENGEAL

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    Enrico,

    The issue is because the function is not included due to the #ifdef. Technically the dump scanner can attempt to parse #ifdef to avoid generation of the entry into the symbol table but I am not sure this is desired. Can you please provide a real world
    sample where such case can exist intentionally? I mean if the function is in the BEGINDUMP than it will likely also have a prg code calling it so I don't understand what can be a real world case of such issue. Even if there was such case, I suppose it is
    much simpler to have a PRG level #ifdef around the #pragma BEGINDUMP. - or maybe I just don't understand the problem.

    Ron

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Wed Sep 20 11:31:55 2023
    Il 20/09/2023 01:02, Ron Pinkas ha scritto:

    The issue is because the function is not included due to the #ifdef. Technically the dump scanner can attempt to parse #ifdef to avoid generation of the entry into the symbol table but I am not sure this is desired. Can you please provide a real
    world sample where such case can exist intentionally? I mean if the function is in the BEGINDUMP than it will likely also have a prg code calling it so I don't understand what can be a real world case of such issue. Even if there was such case, I suppose
    it is much simpler to have a PRG level #ifdef around the #pragma BEGINDUMP. - or maybe I just don't understand the problem.

    Imagine you want to define a function only for 64-bit mode compilation.
    Well, you can't:


    FUNCTION MAIN()

    RETURN NIL


    #pragma BEGINDUMP

    #ifdef _WIN64

    HB_FUNC( MYFUNC64 )
    {
    }

    #endif

    #pragma ENDDUMP

    In 32-bit mode:

    error LNK2001: unresolved external symbol _HB_FUN_MYFUNC64

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ron Pinkas@21:1/5 to Enrico Maria Giordano on Wed Sep 20 07:13:36 2023
    On Wednesday, September 20, 2023 at 4:31:56 AM UTC-5, Enrico Maria Giordano wrote:
    Il 20/09/2023 01:02, Ron Pinkas ha scritto:

    The issue is because the function is not included due to the #ifdef. Technically the dump scanner can attempt to parse #ifdef to avoid generation of the entry into the symbol table but I am not sure this is desired. Can you please provide a real
    world sample where such case can exist intentionally? I mean if the function is in the BEGINDUMP than it will likely also have a prg code calling it so I don't understand what can be a real world case of such issue. Even if there was such case, I suppose
    it is much simpler to have a PRG level #ifdef around the #pragma BEGINDUMP. - or maybe I just don't understand the problem.
    Imagine you want to define a function only for 64-bit mode compilation. Well, you can't:
    FUNCTION MAIN()

    RETURN NIL


    #pragma BEGINDUMP
    #ifdef _WIN64

    HB_FUNC( MYFUNC64 )
    {
    }

    #endif

    #pragma ENDDUMP

    In 32-bit mode:

    error LNK2001: unresolved external symbol _HB_FUN_MYFUNC64
    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    Enrico,

    Of course you can:

    #ifdef WIN64

    #pragma BEGINDUMP

    HB_FUNC( SCAVENGEAL )
    {
    }

    #endif

    #pragma ENDDUMP

    #endif

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ron Pinkas@21:1/5 to Enrico Maria Giordano on Wed Sep 20 08:07:40 2023
    On Wednesday, September 20, 2023 at 9:26:50 AM UTC-5, Enrico Maria Giordano wrote:
    Il 20/09/2023 16:13, Ron Pinkas ha scritto:

    Imagine you want to define a function only for 64-bit mode compilation. >> Well, you can't:

    FUNCTION MAIN()

    RETURN NIL


    #pragma BEGINDUMP
    #ifdef _WIN64

    HB_FUNC( MYFUNC64 )
    {
    }

    #endif

    #pragma ENDDUMP

    In 32-bit mode:

    error LNK2001: unresolved external symbol _HB_FUN_MYFUNC64

    Of course you can:

    #ifdef WIN64

    #pragma BEGINDUMP

    HB_FUNC( SCAVENGEAL )
    {
    }

    #endif

    #pragma ENDDUMP

    #endif
    Yes, I know, but with Harbour it works in this form too:
    FUNCTION MAIN()

    RETURN NIL


    #pragma BEGINDUMP

    #ifdef _WIN64

    HB_FUNC( MYFUNC64 )
    {
    }

    #endif

    #pragma ENDDUMP
    Can we fix it?
    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    Enrico, I believe the "fix" is wrong - As the documentation in inline_c.txt clearly states:

    -------
    #PRAGMA BEGINDUMP
    * ...
    * [#PRAGMA ENDDUMP]|EOF
    *
    * The transition from Harbour to C* occurs when encountering the FIRST NewLine token, at the end of the #pragme BEGINDUMP directive line. The transition from C* back to Harbour occurs when encountering the FIRST NewLine token, at the *end* of the
    FIRST FOUND line containing a #pragma ENDDUMP directive, or at the EOF.
    *
    * There may be any number of lines in such C* block. Any legal C* syntax including #directives, and any number of nested balanced {} is allowed.
    *
    * Misc:
    *
    *
    * C* Syntax errors and warnings, are reported with the correct PRG source file name, and line number.
    *
    * No parsing of the C* code is being performed, and thus MACROS of unbalanced '{}' are allowed.
    *
    * This implementation is actually language independent, and will allow inclusion of any code compatible with the generated output

    -----

    It's up to the Programmer to make sure that the dumped section is valid in the context of the PRG compilation unit. Also, since such function clearly must be called from the PRG code at SOME TIME to be of value, then the PRG code *MUST* have such #ifdef
    anyway!

    Ron

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Wed Sep 20 16:26:49 2023
    Il 20/09/2023 16:13, Ron Pinkas ha scritto:

    Imagine you want to define a function only for 64-bit mode compilation.
    Well, you can't:

    FUNCTION MAIN()

    RETURN NIL


    #pragma BEGINDUMP
    #ifdef _WIN64

    HB_FUNC( MYFUNC64 )
    {
    }

    #endif

    #pragma ENDDUMP

    In 32-bit mode:

    error LNK2001: unresolved external symbol _HB_FUN_MYFUNC64

    Of course you can:

    #ifdef WIN64

    #pragma BEGINDUMP

    HB_FUNC( SCAVENGEAL )
    {
    }

    #endif

    #pragma ENDDUMP

    #endif

    Yes, I know, but with Harbour it works in this form too:

    FUNCTION MAIN()

    RETURN NIL


    #pragma BEGINDUMP

    #ifdef _WIN64

    HB_FUNC( MYFUNC64 )
    {
    }

    #endif

    #pragma ENDDUMP

    Can we fix it?

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Enrico Maria Giordano@21:1/5 to All on Wed Sep 20 17:22:49 2023
    Il 20/09/2023 17:07, Ron Pinkas ha scritto:

    Enrico, I believe the "fix" is wrong

    Ok, no problem.

    --
    Enrico Maria Giordano

    http://www.emagsoftware.it
    http://www.emagsoftware.it/emgmusic
    http://www.emagsoftware.it/spectrum
    http://www.emagsoftware.it/tbosg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)