diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5a9f0e2181..7d1c134b57 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,21 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-03-05 14:34 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbdefs.h + * harbour/source/vm/hvm.c + * respect HB_START_PROCEDURE in all builds if such public + function/procedure exists. + Now whole Harbour code can be compiled with -n1 in all builds. + Warning for Windows/DOS users: + if you have main() function in your .prg code then it will be + automatically detected as application startup entry just like + in other systems. + Otherwise the 1-st linked function will be used like so far. + + added HB_START_PROC_STRICT macro which causes that HVM ignores + HB_FS_FIRST attribute. Before this modification HB_START_PROCEDURE + has such meaning. + 2009-03-05 12:48 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/hbgtcore.c * small modification in instruction order as workaround for PellesC bug diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index bf2699a76f..849aa0b8ed 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -1227,16 +1227,12 @@ typedef unsigned long HB_COUNTER; /* *********************************************************************** * The name of starting procedure * Note: You have to define it in case when Harbour cannot find the proper - * starting procedure (due to incorrect order of static data initialization) - * - * The list of compilers that require it: - * - Watcom C/C++ 10.0 - * - GCC on Linux - * - * By default we are using automatic lookup (symbol not defined) -*/ -#if defined(__WATCOMC__) || defined(__DMC__) || ( defined(__GNUC__) && !defined(__DJGPP__) && !defined(HB_OS_OS2_GCC) ) - #define HB_START_PROCEDURE "MAIN" + * starting procedure (due to unknown order of static data initialization) + */ +#define HB_START_PROCEDURE "MAIN" +#if defined(__WATCOMC__) || defined(__DMC__) || \ + ( defined(__GNUC__) && !defined(__DJGPP__) && !defined(HB_OS_OS2_GCC) ) + #define HB_START_PROC_STRICT #endif #if defined(HB_FUNC_CALLCONV) diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 745a73531e..83df052d11 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -944,41 +944,57 @@ void hb_vmInit( BOOL bStartMainProc ) if( pDynSym && pDynSym->pSymbol->value.pFunPtr ) s_pSymStart = pDynSym->pSymbol; -#ifdef HB_START_PROCEDURE else { /* if first char is '@' then start procedure were set by - programmer explicitly and should have the highest priority - in other case it's the name of first public function in - first linked moudule which is used if there is no - HB_START_PROCEDURE in code */ + * programmer explicitly and should have the highest priority + * otherwise it's the name of first public function in + * first linked module which is used if there is no + * HB_START_PROCEDURE in code + */ + const char * pszMain; + if( s_vm_pszLinkedMain && *s_vm_pszLinkedMain == '@' ) - pDynSym = hb_dynsymFind( s_vm_pszLinkedMain + 1 ); + { + pszMain = s_vm_pszLinkedMain + 1; + pDynSym = hb_dynsymFind( pszMain ); + } else { - pDynSym = hb_dynsymFind( HB_START_PROCEDURE ); - - if( ! ( pDynSym && pDynSym->pSymbol->value.pFunPtr ) && s_vm_pszLinkedMain ) - pDynSym = hb_dynsymFind( s_vm_pszLinkedMain ); +#ifndef HB_START_PROCEDURE + pszMain = NULL; +#else + pszMain = HB_START_PROCEDURE; + pDynSym = hb_dynsymFind( pszMain ); + if( ! ( pDynSym && pDynSym->pSymbol->value.pFunPtr ) ) +#endif + { + if( s_vm_pszLinkedMain ) + { + pszMain = s_vm_pszLinkedMain; + pDynSym = hb_dynsymFind( pszMain ); + } + } } if( pDynSym && pDynSym->pSymbol->value.pFunPtr ) s_pSymStart = pDynSym->pSymbol; +#ifdef HB_START_PROC_STRICT else - hb_errInternal( HB_EI_VMBADSTARTUP, NULL, HB_START_PROCEDURE, NULL ); - } -#else - else if( s_vm_pszLinkedMain ) - { - pDynSym = hb_dynsymFind( s_vm_pszLinkedMain + ( *s_vm_pszLinkedMain == '@' ? 1 : 0 ) ); - if( pDynSym && pDynSym->pSymbol->value.pFunPtr ) - s_pSymStart = pDynSym->pSymbol; - } + /* clear startup symbol set by initialization code */ + s_pSymStart = NULL; +#endif + #ifndef HB_C52_STRICT - if( bStartMainProc && ! s_pSymStart ) - hb_errInternal( HB_EI_VMNOSTARTUP, NULL, NULL, NULL ); -#endif + if( bStartMainProc && ! s_pSymStart ) + { + if( pszMain ) + hb_errInternal( HB_EI_VMBADSTARTUP, NULL, pszMain, NULL ); + else + hb_errInternal( HB_EI_VMNOSTARTUP, NULL, NULL, NULL ); + } #endif + } } if( bStartMainProc && s_pSymStart ) @@ -1003,7 +1019,6 @@ void hb_vmInit( BOOL bStartMainProc ) } hb_vmDo( ( USHORT ) iArgCount ); /* invoke it with number of supplied parameters */ - } }