Click to See Complete Forum and Search --> : Noob ask about ermmm using the same include file for multiple "objects" in C


irb4
September 12th, 2006, 06:12 AM
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!

TomWidmer
September 12th, 2006, 08:12 AM
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.

irb4
September 14th, 2006, 11:20 PM
Thank you very much! Great help.