v5.00 External procedures, unexpected error message

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:

v5.00 External procedures, unexpected error message

#1 Post by Dany » 09 Jul 2011 16:36

Hi,

Why is it not allowed to define procedures as "external" when they reside in a library checked in the library manager?

Example:

Code: Select all

{$IFDEF MMC} // for the mmc library (should be checked in the library manager)
function Mmc_Read_Sector(sector: longint; var dbuff: array[512] of byte): byte; external;
function Mmc_Write_Sector(sector: longint; var data_: array[512] of byte): byte;  external;
{$ENDIF}
gives "Identifier 'Mmc_Read_Sector' already declared in '__Lib_Mmc.mpas' " error on the first code line above if the Mmc lib is checked in the library manager.

If such lines are commented out the error disappears.

I have seen also that "using" a library in a unit also prohibits that the library's routines can be declared external in that unit.

Above means also that faultless compiling of a unit depends on the fact that another library is checked in the library manager or not (a thing one does not can foresee when designing a unit that uses external procedures). Problems as above can pop up when e.g. users start to put .mcl files in packages and using them.

Of course, declaring routines external which are in 'libraries' is not necessary, but
- why is it forbidden?
- why is the error message not helpfull at all?


Thanks in advance!
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: v5.00 External procedures, unexpected error message

#2 Post by filip » 11 Aug 2011 11:48

Hi,

This error notifies users that the desired routine is visible, i.e. that no redeclaration is necessary to use it.
Do you have some specific project/case where you need this redeclaration ?

Regards,
Filip.

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

Re: v5.00 External procedures, unexpected error message

#3 Post by Dany » 11 Aug 2011 20:12

Hi Filip,
filip wrote:This error notifies users that the desired routine is visible, i.e. that no redeclaration is necessary to use it.
Yes I know redeclaration is not necessary, but why is it forbidden?
filip wrote:Do you have some specific project/case where you need this redeclaration ?
Not for the moment, but as soon as I will start to use packages and check certain units in a package as "used" then I will have those problems. My projects sometime use routines from a unit in a package, but the unit which deliveres the routine can differ: the routine sometimes is present in unit A, sometimes in unit B. Hence the "external" declarations: the unit name which contains the used routine does not have to be known in advance.
Of course unchecking the unit in the lib manager also solve the problem (the solution is not very nice though).
It would be perhaps better if the "external" statement would be ignored if the desired routine is already (for some reason) visible... :?
I have seen also that "using" a library in a unit also prohibits that the library's routines can be declared external in that unit.
Also here: of course the external declaration is not necessary if the routine is in a unit in the uses clause, but why is it forbidden?


The first issue poses the biggest problem for me (I would like to use packages), the latter is a minor one.
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”