Page 1 of 1

How can I use a "C variable" on PB?

Posted: Mon Jan 30, 2023 1:39 pm
by IceSoft

Code: Select all

!//	int found = 11;
Debug "found: " + Str(found)
output: found: 0

What is wrong?

Re: How can I use a "C variable" on PB?

Posted: Mon Jan 30, 2023 1:42 pm
by STARGÅTE

Code: Select all

! int v_found = 11;
Debug "found: " + Str(found)

Re: How can I use a "C variable" on PB?

Posted: Mon Jan 30, 2023 2:13 pm
by IceSoft
STARGÅTE wrote: Mon Jan 30, 2023 1:42 pm

Code: Select all

! int v_found = 11;
Debug "found: " + Str(found)
thanks!
For what stands 'v_' => Variable?
's_' is Strucure?
Is there any documentation about all 'previxes"

Re: How can I use a "C variable" on PB?

Posted: Mon Jan 30, 2023 2:16 pm
by Fred
there is no doc, but you can create the commented output to see how it is built. For example accessing a module variable is more complex

Re: How can I use a "C variable" on PB?

Posted: Mon Jan 30, 2023 2:28 pm
by STARGÅTE
for the ASM backend it is written here:
https://www.purebasic.com/documentation ... edasm.html
- The used variables or pointers must be declared before to use them in an assembler keyword. Their names in assembler are 'v_variablename' and 'p_pointername', and in a procedure their names are 'p.v_variablename' and 'p.p_pointername'.
- Labels: The labels need to be referenced in lowercase when using the in-line ASM. When you reference a label, you must put the prefix 'l_' before the name.
If the label is defined in a procedure, then its prefix is 'll_procedurename_', in lowercase.
When you reference a module item, you must put the prefix 'module_name.l_' all in lowercase before the item.
If the label is defined in a procedure inside a module, then its prefix is 'module_name.ll_procedurename_', in lowercase.