Naming "Feature" with Harbour Compiler?

Post Reply
User avatar
xProgrammer
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Naming "Feature" with Harbour Compiler?

Post by xProgrammer »

Hi all

It seems that if I use the same name for the source file of a class as the class itself ( for example CLASS myclass in file myclass.prg ) the harbour compiler gives an error, namely:

Error F0002 Redefinition of procedure or function: 'MYCLASS'
1 error

and the compilation ( to C source ) fails.

Is this correct / normal behaviour? Certainly xHarbour doesn't have any such problem.

Is this why so many classes are prefaced with a "T" ?

Thanks
xProgrammer
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Doug,

This code is working fine here. Remember to use the flag /n :

myclass.prg

Code: Select all

#include "FiveWin.ch"

function Main()

   local o := MyClass():New()

   MsgInfo( o:ClassName() )

return nil

CLASS MyClass

   METHOD New() INLINE Self

ENDCLASS
> Is this why so many classes are prefaced with a "T" ?

Thats a tradition started from Borland code. They used "T" to distinct between a function name and a Class name. "T" was used for "Type".
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply