I can't recommend doing that in any application as
these are not guaranteed interfaces/structures, plus
it may cause several other problems (alignment
dependence, corrupting VM internals, MT/ST mode
dependence, code breaking when Harbour internals
happen to change).

ok Viktor, I see. That's what happened indeed.

So my suggestion it to use the documented Harbour
C API. You can find these in hbapi*.h headers for
the most part.

Sure. Could you tell me how to do the following through the C API?

1) get the length of the array, instead of method below:

PHB_BASEARRAY pBaseArray = pArray->item.asArray.value;
ULONG ulLen = pBaseArray->ulLen ;

2) eval a codeblock with a member of the array as a parameter and get the return of the block, instead of the following:
HB_STACK_TLS_PRELOAD
hb_vmPushSymbol( &hb_symEval );
hb_vmPush( pBlock );
hb_vmPush( pBaseArray->pItems + ulPosition );
hb_vmPushLong( ulPosition );
hb_vmSend( 2 );
pItem = (PHB_ITEM) hb_stackReturnItem();

Thank you
Leandro
--------------------------------------------------
From: "Viktor Szakáts" <harbour...@syenar.hu>
Sent: Saturday, January 30, 2010 8:58 PM
To: "Harbour Project Main Developer List." <harbour@harbour-project.org>
Subject: Re: [Harbour] undefined reference to 'hb_stack'

Hi,

Probably you try to use internals in your .c code.
(accessing HB_BASEARRAY f.e.)

I can't recommend doing that in any application as
these are not guaranteed interfaces/structures, plus
it may cause several other problems (alignment
dependence, corrupting VM internals, MT/ST mode
dependence, code breaking when Harbour internals
happen to change).

In fact not even Harbour RTL and other libs
except VM are allowed to use them.

So my suggestion it to use the documented Harbour
C API. You can find these in hbapi*.h headers for
the most part.

I guess most things can be solved with it; if not,
you may describe the situation and if justified
and doable we can add new API functions.

Brgds,
Viktor

On 2010 Jan 30, at 23:43, Leandro Damasio wrote:

Viktor Szakáts wrote:
Just delete '#include "hbvmopt.h"', it's an internal header, not needed.

After supressing hbvmopt.h I get a lot compile errors. This hb_arraySeek function is based upon hb_arrayScan and is quite similar to it and so it seems to need hbvmopt.h to be compiled. Without hbvmopt.h I get the compile errors listed below and with hbvmopt.h the compile goes fine but the linkage doesn't work (undefined reference to 'hb_stack' error), but before the change to harbour 2.0 it was possible to compile the same code normally.
Any directions?
Thanks,
Leandro

-----------------------------------------------------------------------------------
D:\as>hbmk2 -hblib -oas array.prg array0.c aseek.c
hbmk2: Processando opções do ambiente: -compiler=mingw
hbmk2: Processando arquivo de configuração: D:\HARBOUR\BIN\hbmk.cfg
Harbour 2.1.0dev (Rev. 13736)
Copyright (c) 1999-2010, http://www.harbour-project.org/
Compiling 'array.prg'...
Lines 1112, Functions/Procedures 4
Generating C source output to 'array.c'... Done.
gcc.exe: aseek.c: No such file or directory
array0.c: In function `hb_arraySeek':
array0.c:15: error: `PHB_BASEARRAY' undeclared (first use in this function)
array0.c:15: error: (Each undeclared identifier is reported only once
array0.c:15: error: for each function it appears in.)
array0.c:15: error: syntax error before "pBaseArray"
array0.c:27: error: `pBaseArray' undeclared (first use in this function)
array0.c:42: error: `HB_STACK_TLS_PRELOAD' undeclared (first use in this function)
array0.c:42: error: syntax error before "hb_vmPushSymbol"
array0.c:70: error: syntax error before "hb_vmPushSymbol"
array0.c:125: error: syntax error before "hb_vmPushSymbol"
array0.c:150: error: syntax error before "hb_vmPushSymbol"
array0.c: In function `hb_arrayItemCmp':
array0.c:325: warning: dereferencing `void *' pointer
array0.c:325: error: request for member `item' in something not a structure or union
array0.c:325: warning: dereferencing `void *' pointer
array0.c:325: error: request for member `item' in something not a structure or union
array0.c:326: warning: dereferencing `void *' pointer
array0.c:326: error: request for member `item' in something not a structure or union
array0.c:326: warning: dereferencing `void *' pointer
array0.c:326: error: request for member `item' in something not a structure or union
array0.c:327: warning: dereferencing `void *' pointer
array0.c:327: error: request for member `item' in something not a structure or union
array0.c:327: warning: dereferencing `void *' pointer
array0.c:327: error: request for member `item' in something not a structure or union
array0.c:328: warning: dereferencing `void *' pointer
array0.c:328: error: request for member `item' in something not a structure or union
array0.c:328: warning: dereferencing `void *' pointer
array0.c:328: error: request for member `item' in something not a structure or union
array0.c:337: warning: dereferencing `void *' pointer
array0.c:337: error: request for member `item' in something not a structure or union
array0.c:337: warning: dereferencing `void *' pointer
array0.c:337: error: request for member `item' in something not a structure or union
array0.c:338: warning: dereferencing `void *' pointer
array0.c:338: error: request for member `item' in something not a structure or union
array0.c:338: warning: dereferencing `void *' pointer
array0.c:338: error: request for member `item' in something not a structure or union array0.c:346: warning: implicit declaration of function `HB_ITEM_GET_NUMINTRAW'
array0.c: At top level:
array0.c:13: warning: unused parameter 'pArray'
hbmk2: Erro: Executando compilador C/C++. 1
gcc.exe -c -O3 -march=i586 -mtune=pentiumpro -fomit-frame-pointer -Wall -W -Id:
/harbour/include array.c array0.c aseek.c


--------------------------------------------------
From: "Viktor Szakáts" <harbour...@syenar.hu>
Sent: Friday, January 29, 2010 11:39 PM
To: "Harbour Project Main Developer List." <harbour@harbour-project.org>
Subject: Re: [Harbour] undefined reference to 'hb_stack'

Just delete '#include "hbvmopt.h"', it's an internal header, not needed.

Brgds,
Viktor

On 2010 Jan 30, at 02:34, Leandro Damasio wrote:

Hi
Attempting to build a program with the function below I receive the following linkage error message:
undefined reference to `hb_stack'
The error is related to hb_retnint and hb_retni calls, because when I ommit them the error message goes away.
What is wrong with the code please?

Thank you
Leandro

------------------------------------------------------

code (aseek.c)

#include "hbvmopt.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbvm.h"
#include "hbstack.h"

ULONG hb_arraySeek( PHB_ITEM pArray, PHB_ITEM pValue, PHB_ITEM pBlock, BOOL bSoft , BOOL bExact, PHB_ITEM pMode );

HB_FUNC( ASEEK )
{
   PHB_ITEM pArray = hb_param( 1, HB_IT_ARRAY );
   PHB_ITEM pValue = hb_param( 2, HB_IT_ANY );
   PHB_ITEM pBlock = hb_param( 3, HB_IT_ANY );
   if( pArray && pValue )
   {
       BOOL bSoft = HB_ISLOG( 4 ) ? hb_parl ( 4 ): FALSE;
       BOOL bExact = HB_ISLOG( 5 ) ? hb_parl ( 5 ): FALSE;
       PHB_ITEM pMode = hb_param( 6, HB_IT_NUMINT );
hb_retnint( hb_arraySeek( pArray, pValue, pBlock, bSoft, bExact ,pMode ) );
   }
   else
       hb_retni( 0 );
}

ULONG hb_arraySeek( PHB_ITEM pArray, PHB_ITEM pValue, PHB_ITEM pBlock, BOOL bSoft , BOOL bExact, PHB_ITEM pMode )
{
...
}

/code (aseek.c)


hbide output console
----------------------------------------------------------------------------------------------------
Project [ 2DT ] Launch [ No ] Rebuild [ No ] Started [ 23:04:23 ]
----------------------------------------------------------------------------------------------------
Starting in: qt\4.5.3\bin : D:\2DL\FONTES\T_FONTES
hbmk2: Processando op‡äes do ambiente: -compiler=mingw
hbmk2: Processando arquivo de configura‡Æo: D:\HARBOUR\BIN\hbmk.cfg
hbmk2: Linha de comando do compilador Harbour: (interno)
(D:\HARBOUR\BIN\harbour.exe) -n2 D:/2DL/FONTES/T_FONTES/2DT.PRG -q -id:/harbour/include -iD:/2DL/INCLUDE/GENERAL -iD:/2DL/INCLUDE/HB_2 -iD:/2DL/INCLUDE/2DWGUI
Harbour 2.1.0dev (Rev. 13736)
Copyright (c) 1999-2010, http://www.harbour-project.org/
hbmk2: Comando do compilador C/C++:
gcc.exe -c -O3 -march=i586 -mtune=pentiumpro -fomit-frame-pointer -Wall -W -Id:/harbour/include -ID:/2DL/INCLUDE/GENERAL -ID:/2DL/INCLUDE/HB_2 -ID:/2DL/INCLUDE/2DWGUI 2DT.c C:\Users\Leo\AppData\Local\Temp\hbmk_tz229x.c
hbmk2: Comando do Linkeditor:
gcc.exe 2DT.o hbmk_tz229x.o -mconsole -Wl,--start-group -l2dwgui -l2dbase -l2dsmart -lhbwin -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,--end-group -oD:/2DL/EXE/2DT.exe -Ld:/harbour/lib/win/mingw -LD:/2DL/LIBS/2DWGUI -LD:/2DL/LIBS/2DBASE -LD:/2DL/LIBS/2DSMART D:/2DL/LIBS/2DSMART/lib2dsmart.a(ASEEK.o):ASEEK.C:(.text+0xee): undefined reference to `hb_stack' D:/2DL/LIBS/2DSMART/lib2dsmart.a(ASEEK.o):ASEEK.C:(.text+0x113): undefined reference to `hb_stack'
collect2: ld returned 1 exit status
hbmk2: Erro: Executando linkeditor. 1
gcc.exe 2DT.o hbmk_tz229x.o -mconsole -Wl,--start-group -l2dwgui -l2dbase -l2dsmart -lhbwin -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,--end-group -oD:/2DL/EXE/2DT.exe -Ld:/harbour/lib/win/mingw -LD:/2DL/LIBS/2DWGUI -LD:/2DL/LIBS/2DBASE -LD:/2DL/LIBS/2DSMART
----------------------------------------------------------------------------------------------------
Exit Code [ 7 ] Exit Status [ 0 ] Finished at [ 23:04:24 ] Done in [ 0.93 Secs ]
----------------------------------------------------------------------------------------------------
/hdide output console
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to