Using constants defined elsewhere in libraries (Ok)

Beta Testing discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Using constants defined elsewhere in libraries (Ok)

#1 Post by Dany » 12 May 2011 12:28

Hi, I have encountered a problem when using constants, defined in a unit used by the library, in compiled libraries (.mcl files), no source code present:

Apparently constant values, defined in a unit used by the library, are only taken during compilation time of the library, and once the library (.mcl file) is used stand alone (without source file), any changes to the constant value is ignored.

Example: library "USB_HID_Library.mcl" uses unit "USB_HID_ProjectItems" wherein the constants "VENDOR_ID" and "PRODUCT_ID" are defined. The values are used in a const table in the "USB_HID_Library.mcl" library (see my previous post).
The unit "USB_HID_ProjectItems" is different for every project, while "USB_HID_Library.mcl" is the common library to make HID products.
If the project only sees "USB_HID_Library.mcl", and not its source, then the generated USB HID product has always the Vendor_id and the Product_id that were used during initial compilation of "USB_HID_Library.mcl".

This is a problem when distributing only the .mcl files of libraries.


I assume this issue is not easy to solve. Perhaps there is a work around?
(One solution is to move the table using the constant values from "USB_HID_Library.mcl" to "USB_HID_ProjectItems", but I would like to keep it in "USB_HID_Library.mcl" for better encapsulation.)

Thanks in advance!
Last edited by Dany on 09 Jun 2011 18:04, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

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

Re: Problem using constants defined elsewhere in libraries

#2 Post by filip » 02 Jun 2011 09:45

Hi,

I apologize for the late reply.
Please, can you provide me with the example which demonstrates this issue ?

Regards,
Filip.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Problem using constants defined elsewhere in libraries

#3 Post by Dany » 09 Jun 2011 18:04

filip wrote:Please, can you provide me with the example which demonstrates this issue ?
Hi Philip, I think you can ignore this thread, I do not think it can be solved due to the nature of libraries (of which only the .mcl file is available).
Furthermore I did use the workaround I mentioned in the first post.

So, please do not bother further about this one!

Many thanks! :D :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for PIC Beta Testing”