Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating Libraries for use by C programs
#1
Guys,

Please excuse me if I sound stupid on this -- it's been a while
that I've been playing with PDS and I'm only now getting back
into this stuff.

I recently started looking for new 32 bit basic compilers,
and I found FB, and also PowerBasic Console Compiler.
My objective was to start writing some libraries that other
C programmers here could call from their applications. I don't
know C, and it looks too weird for me to deal with.

So I thought I could make some statically linkable libraries,
that would share global variables with their C applications.
I've never used pointers to memory, and it seems like a pain
in the butt, so I'd rather just have simple global variables
between my libraries and the main C programs. For example,
I want my library functions to create arrays that are read by
the C program e.g., A(X,Y,Z). So these array variables need
to be global between the library and the main C programs.

First I had gotten the PB/CC, and I came to read in their manual
that they don't support static libraries, and you can't have global
variables between a pb .DLL and the calling program -- you have to
pass paramaters to the .DLL. But I want my library to maintain
the arrays that are read by the main C program based on some
database I/O and TCP/IP connections that the library code would
be handling. The C programs would just be reading the arrays.

So, that brings me to FB -- will I have the same issue with FB
as I do with PB? Can I create libraries, preferably static libraries,
in FB, which will be able to share global variables with a C program
as long as they are declared in a certain way? I don't want
to deal with memory address pointers if I don't have to.
I want my library code to create/update variables in an array
like A(X,Y,Z), which the main C code can read. I thought all that
I would have had to do is make sure that the arrays are declared
the right way.

I can't do that with PB/CC as far as I can tell from their manual.
So, please tell me that I can do that with FB, or what you
suggest that's along these lines. And again, sorry if I sound like
an idiot, but it's been a while.

Dean
Reply
#2
FB can creat static and dynamic but dude you can pass an array to dll or rather a pointer.

mybe somone else can fill in more details about this.
Reply
#3
My example is that my library code maintains a socket
connection and does database file i/o, and based on that
it maintains certain data stored in huge multidimensional
arrays which the main C program is reading. I want the
C program to reference the arrays by their variable names.

E.g., I decide in my FB library code that A(1,2,3) = 1.
The C program is looking for the value of A(1,2,3) in its code
and needs to see the value is = 1. Are you saying I can
do that?

Dean
Reply
#4
declare function test (byref temp() as integer) as integer
DIM B(100) as integer
DIM Bptr as integer ptr
b(0) = 100
b(1) = 234

X% = test(B())
sleep
end

function test (byref T() as integer) as integer
for X% = 0 to 10
print T(x%)
next
end function

'
' ok now just pretend the fuction test was in a DLL you made
' as long as you used byref T() then what will happen is
' when your dll is load which if your program called the dll then it will
' be with in the C programs memorey map then as long the C
' program pass the array the FB dll will act on it by refrence
' meaning it will act on it like a pointer to that array. there a dll
' example in FB package
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)