[Done] Pointer to a structure in the prototype

Post bugreports for the Windows version here
User_Russian
Addict
Addict
Posts: 1549
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

[Done] Pointer to a structure in the prototype

Post by User_Russian »

Code: Select all

Macro ma_result : l : EndMacro
PrototypeC.ma_result p_onContextInit(*pContext.ma_context,  *pConfig.ma_context_config,  *pCallback.sma_backend_callbacks)
For prototype does not need to know what implementation of the structure is (the structure is declared below the prototype), because it is a pointer and it is always 4 or 8 bytes and not depend of the implementation of the structure.
User avatar
NicTheQuick
Addict
Addict
Posts: 1523
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Pointer to a structure in the prototype

Post by NicTheQuick »

Is that a bug report? I don't see any bug here. Please give more context.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
Demivec
Addict
Addict
Posts: 4270
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Pointer to a structure in the prototype

Post by Demivec »

User_Russian wrote: Tue Sep 09, 2025 4:13 pm

Code: Select all

Macro ma_result : l : EndMacro
PrototypeC.ma_result p_onContextInit(*pContext.ma_context,  *pConfig.ma_context_config,  *pCallback.sma_backend_callbacks)
For prototype does not need to know what implementation of the structure is (the structure is declared below the prototype), because it is a pointer and it is always 4 or 8 bytes and not depend of the implementation of the structure.
Pointers can't be declared with native types like '.l' .
User_Russian
Addict
Addict
Posts: 1549
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Pointer to a structure in the prototype

Post by User_Russian »

NicTheQuick wrote: Tue Sep 09, 2025 6:20 pm Is that a bug report? I don't see any bug here. Please give more context.
Image

ma_context, ma_context_config and sma_backend_callbacks these are structures that are declared after the prototype.
Demivec wrote: Tue Sep 09, 2025 6:36 pmPointers can't be declared with native types like '.l' .
There are no pointers with native PB types in this code.
User avatar
mk-soft
Always Here
Always Here
Posts: 6252
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Pointer to a structure in the prototype

Post by mk-soft »

One pass compiler. You mast define the structure before.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Pointer to a structure in the prototype

Post by Fred »

As it's a pointer, it should work. I will take a closer look
User_Russian
Addict
Addict
Posts: 1549
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Pointer to a structure in the prototype

Post by User_Russian »

Similar problem with keyword Declare

Code: Select all

Declare Proc(*z.struct)

Structure struct
  Param1.l
  Param2.f
EndStructure

Procedure Proc(*z.struct)
  
EndProcedure
and Define

Code: Select all

Define *z.struct

Structure struct
  Param1.l
  Param2.f
EndStructure

*z\Param1=0
Import : EndImport

Code: Select all

Import "User32.lib"
  GetWindowRect(hWnd, *r.MyRECT)
EndImport
User avatar
mk-soft
Always Here
Always Here
Posts: 6252
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Pointer to a structure in the prototype

Post by mk-soft »

It has never been possible to use structures that were only defined after their first use.

Normal behaviour

Code: Select all

Procedure foo(*d.udtFoo)   
  
EndProcedure

Structure udtFoo
  d1.i
  d2.i
EndStructure
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
NicTheQuick
Addict
Addict
Posts: 1523
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Pointer to a structure in the prototype

Post by NicTheQuick »

mk-soft wrote: Tue Sep 09, 2025 11:14 pmIt has never been possible to use structures that were only defined after their first use.
You're not completely right. It works in structures:

Code: Select all

Structure Foo
	*pointer.Bar
EndStructure

Structure Bar
	a.i
	b.i
EndStructure

Define a.Foo
a\pointer = 1

Debug a\pointer
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Fred
Administrator
Administrator
Posts: 18247
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Pointer to a structure in the prototype

Post by Fred »

I implemented forward declaration for variable pointer for Declare() and Prototype().
User avatar
NicTheQuick
Addict
Addict
Posts: 1523
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: [Done] Pointer to a structure in the prototype

Post by NicTheQuick »

Nice
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply