CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2006
    Posts
    36

    Talking Noob ask about ermmm using the same include file for multiple "objects" in C

    I want to open 2 serial ports, one port to input data from a GPS device, another port to output the modified data to another computer.

    But i got only one ibmcom3.c file(for on/off and setting up serial port), and this is C code, I cannot make c++ objects, i thought about writing another file say ibmcom3b.c by adding a prefix _b to all the functions and variables of ibmcom3.c, but that's a lot of work.

    Is there a simpler way to do this?


    The main code:
    http://www.boondog.com/tutorials/gps/gps1_5.c

    the ibmcom3.c file for serial link communication
    http://www.boondog.com/tutorials/gps/ibmcom3.zip

    Thanks in advance!

  2. #2
    Join Date
    Apr 2006
    Location
    Nr Cambridge, UK
    Posts
    263

    Re: Noob ask about ermmm using the same include file for multiple "objects" in C

    On Windows, you'd create two separate DLLs that each include the ibmcom code - what platform are you using? If you can modify the IBM code, you could change it so that all the global variables are in a struct together, and a pointer to this struct is passed to every function, so you can have several different structs going at once, to allow you to access multiple ports.

  3. #3
    Join Date
    Sep 2006
    Posts
    36

    Talking Re: Noob ask about ermmm using the same include file for multiple "objects" in C

    Thank you very much! Great help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured