My library problem

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
relinquished
Posts: 222
Joined: 09 Apr 2011 11:08
Location: ITALY / NAPOLI

My library problem

#1 Post by relinquished » 26 Apr 2015 21:03

hello to you in the forum, I found myself in a somewhat complex problem, in practice I wrote two libraries in the same functions, but that difference that one uses a uses spi spi device and software, the problem arises now because I wrote a third library that uses these functions written in the first two, and in practice based on the type of spi used the third library should use the first or the second library, I hope I explained well enough.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: My library problem

#2 Post by filip » 30 Apr 2015 16:42

Hi,

I believe you have been answered on the other topic regarding the same issue.

Regards,
Filip.

relinquished
Posts: 222
Joined: 09 Apr 2011 11:08
Location: ITALY / NAPOLI

Re: My library problem

#3 Post by relinquished » 01 May 2015 18:00

I'm sorry , could you indicate where ??

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: My library problem

#4 Post by aCkO » 02 May 2015 01:41

The solution to your problem is to use function pointer in your third library. That way you can choose which function will be called from the first two libraries.

Example:

Code: Select all

typedef Tfun as sub procedure (dim b as byte)

sub procedure fun1(dim b as byte)    ' function from the first library
   ...
end sub

sub procedure fun2(dim b as byte)    ' function from the second library
   ...
end sub

dim MyFun as ^Tfun
const ver = 1

main:
   if ver = 1 then
      MyFun = @fun1
   else
      MyFun = @fun2
   end if

   MyFun(0x01)
end.
Regards

Post Reply

Return to “mikroBasic PRO for PIC32 General”