Announcement

Collapse
No announcement yet.

Use of library functions of C

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use of library functions of C

    Hello,

    Having the need to convert some code from QuickBasic 4.5
    MicroSoft to PowerBasic 3.5 as this offers more performance,
    I have the following problem: to re-use lots of code C 5.10
    MicroSoft used as a support to QB where it was not particularly
    efficient.

    Hoping that I will not have to write the whole code C again,
    I would like to ask you if (and how) it is possible to use the
    library functions of this language contained in the LLIBCE.LIB.

    Thank you, Giovanni Grandi



    ------------------

  • #2
    This is not possible. You can't include the C runtime library in
    code that is to be linked with PB/DOS.

    You could replace the C runtime routines that you need with your
    own code, of course. Also, you can probably find source code for
    standard C runtime library routines on the Internet.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment


    • #3
      You would surely have had the same problem linking C code
      to QuickBasic? Maybe you haven't used anything from the
      runtime library, or you've already figured out how to get
      the required routines out of the C runtime library.

      I think Tom is perhaps not entirely correct. It is possible
      to extract routines from both Microsoft and Borland libraries
      and save as object files. These can then be linked to your Basic
      program.

      You need to use the correct library for the PowerBasic memory
      model. Also, if the extracted routine references another
      routine in the library, you need to extract that as well, and
      link it in too. Where you might run into trouble is with
      routines that reference external variables.

      I got quite far along with this at one stage. I did successfully
      link some code out of the Microsoft C standard libraries. You
      might like to give it a go if you're interested in solving
      such puzzles. Otherwise Tom's suggestion of downloading
      the required code should work.

      But I ran into an entirely different problem, that caused me
      to abandon the project, or at least postpone it for a while.

      I was unable to link any C code I had which included global
      pointers. Declaring a global pointer was ok, but any attempt to
      do anything with it would cause the link to fail (Error 514:
      Invalid fixup).

      Since I had a lot of C code I wanted to use, I decided
      to do the project in C instead. I haven't got so far with
      it that I can't change my mind though, if anyone is able to
      assist with the use of C pointers declared globally.

      The other area which is difficult when working with C obj
      files is getting the segments sorted out correctly. The faq
      with PBDOS 3.5 didn't help at all using MS C 5 / Quick C /
      Borland C/C++ 4.5. I managed with the latter by fiddling
      around with the settings using the IDE and inspecting the
      obj files to see what segment names it used.

      I hope you do manage to make use of your C code.

      Good luck!




      ------------------

      Comment

      Working...
      X