Doh! Dropped my bug report too soon.
Small code works, but not in larger library. How to debug this?
pbcompilerc wrote:21617 lines processed.
Error: Assembler
error: 'pb_datapointer' undeclared (first use in this function); did you mean 'pb_mapitem'?
pb_datapointer = v_datalabel;
^~~~~~~~~~~~~~
pb_mapitem
purebasic.c1: note: each undeclared identifier is reported only once for each function it appears in
Yes, but dumping C is with pbcompilerc.exe on command line.
I do not know where the IDE compilation puts the amalgamated C file?
The line numbers are slightly different from IDE compile to command line compile because I cannot load resource and images from command line.
Inspecting the command line C file, it did not rename the variable.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Quite the opposite.
2 lines for ASM and 1 line for C backend, and we can use native Read.x within Procedures.
Of course, I would use the pointer approaches if these simpler alternatives were not available.
The same can be said of all PB use.
I use SendMessage() for some gui affects.
I use PB native and custom SQLite api commands.
Whatever gets the job done reliably.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Procedure SetPbDataSectionPtr (*pData)
; ============================================================================
; NAME: SetDataSectionPtr
; DESC: Set the PureBasic internal Datasection DataPointer.
; DESC: The PB_DataPointer is the PB internal variable For the DataPointer
; DESC; used by PB's Read command.
; DESC: We can't access the DataPointer directly in PB-Code. It exists
; DESC: only as variable in the compiled ASM and C-Code.
; RET : -
; ============================================================================
CompilerIf (#PB_Compiler_Backend = #PB_Backend_Asm)
CompilerIf (#PB_Compiler_Processor = #PB_Processor_x86)
!mov eax, [p.p_pData]
!mov [PB_DataPointer], eax
CompilerElse
!mov rax, [p.p_pData]
!mov [PB_DataPointer], rax
CompilerEndIf
CompilerElse
; in C pData must be pdata
!pb_datapointer = (unsigned char *) p_pdata;
CompilerEndIf
EndProcedure
Procedure GetPbDataSectionPtr ()
; ============================================================================
; NAME: GetDataSectionPtr
; DESC: Get the PureBasic internal Datasection DataPointer.
; DESC: The PB_DataPointer is the PB internal variable For the DataPointer
; DESC; used by PB's Read command.
; DESC: We can't access the DataPointer directly in PB-Code. It exists
; DESC: only as variable in the compiled ASM and C-Code.
; RET : -
; ============================================================================
CompilerIf (#PB_Compiler_Backend = #PB_Backend_Asm)
CompilerIf (#PB_Compiler_Processor = #PB_Processor_x86)
!mov eax, [PB_DataPointer]
ProcedureReturn
CompilerElse
!mov rax, [PB_DataPointer]
ProcedureReturn
CompilerEndIf
CompilerElse
!return pb_datapointer;
;!pb_datapointer = (unsigned char *) p_pdata; in C pData must be pdata
CompilerEndIf
EndProcedure
DataSection
_Data:
Data.i 1,2,3,4,5,6,7,8,9,10
EndDataSection
Define *pData, val
Debug "Data Start Pointer = " + ?_Data ; Debug Pointer Data Start
SetPbDataSectionPtr(?_Data) ; same as Restore _Data
Read.i val : Debug val ; 1
Read.i val : Debug val
Read.i val : Debug val
Read.i val : Debug val
Read.i val : Debug val ; 5
Debug "actual Data Pointer = " + GetPbDataSectionPtr() ; actual Read Data Pointer = ?_Data * 40 (5*Size(OfInteger))
Restore _Data ; restore the Data Start Pointer
Debug "Data Start Pointer = " + GetPbDataSectionPtr() ; Debug again Data Start Pointer