Menu

#888 Won't compile due to parameter miscount

closed
nobody
mangling (4)
compiler
2018-09-26
2018-07-18
No

See freebasic forum https://www.freebasic.net/forum/viewtopic.php?f=3&t=26881&p=249624

There is a bug in the freebasic compiler.

There are 9 declare functions in pnglib pblib2.bi

And yet the compiler only complains about one of them.

Code: Select all
declare function PNG_LoadFile stdcall alias "PNG_LoadFile" (byval pPNGInfo as PNGINFO ptr, byval lpFileName as string) as integer

The compiler says "undefined reference to `PNG_LoadFile@16' "

Think about it. the @16 says it needs 4 dwords for the parameters.(16 bytes)

And yet when you look at this function, It only need 2 dwords.(8 bytes)

I put pnglib2.a in notepad++, it mentions "_PNG_LoadFile@8": 2 dwords

This is a bug in freebasic 1.05 !

Discussion

  • MrSwiss

    MrSwiss - 2018-08-07

    Think about it. the @16 says it needs 4 dwords for the parameters.(16 bytes)
    [true, with a "string"!] but:
    Nope, a string is a FreeBASIC Type, consisting of: 1 x ptr and 2 x integer, therefore, 12 bytes (only valid in FBC32!) since, sizes double in FBC x64.

    The declaration should be, on the second parameter:
    byval lpFileName as zstring ptr ...

    Therefore, NO error / bug in the compiler! Simply a fault, in the declaration!

     
  • Jeff Marshall

    Jeff Marshall - 2018-09-26
    • labels: --> mangling
    • status: open --> closed
     
  • Jeff Marshall

    Jeff Marshall - 2018-09-26

    Fixed in commit [d249ff]
    Related to [#890]

    Also,if library is written for fbc, may need to recompile the the library. Sometimes the binary compatibility changes from one version of fbc to the next as bugs are fixed, or features added.

     

    Related

    Bugs: #890
    Commit: [d249ff]


Log in to post a comment.