Page 1 of 1

Question about C-Code

Posted: Wed Aug 10, 2022 12:35 am
by jacdelad
Hi,
I have no knowledge of C, but after the discussion about the volatile variables I got curious and had a look at the code created. I found something that I don't understand:

Code: Select all

// SetGadgetState(progressbar_900,#PB_ProgressBar_Unknown)
integer rr11498=PB_SetGadgetState(v_progressbar_900,-1LL);
The variable "rr11498" (is it a variable?) is never used, except on this line. As far as I understand the result is stored, but not used (I don't use it too). I have found hundreds of lines like this. Isn't that...unnecessary? The same happens with "DisableWindow", though this function never returns anything (=always "0").

Re: Question about C-Code

Posted: Wed Aug 10, 2022 5:10 am
by idle
yes it's a PBcompilerc generated variable and it will get eliminated by the c compiler as it's unused, it's probably there because it clears up any ambiguity generating the c translation, the compiler will be checking the PB syntax and also evaluating the statements so it generates a variable to satisfy the rules of a binary operand.

Re: Question about C-Code

Posted: Wed Aug 10, 2022 5:34 am
by jacdelad
Ah ok. So no unused memory wasted.

Re: Question about C-Code

Posted: Wed Aug 10, 2022 6:22 am
by idle
yes it'll be removed from the assembly.