Question about C-Code

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Question about C-Code

Post 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").
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Question about C-Code

Post 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.
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Question about C-Code

Post by jacdelad »

Ah ok. So no unused memory wasted.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
idle
Always Here
Always Here
Posts: 5042
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Question about C-Code

Post by idle »

yes it'll be removed from the assembly.
Post Reply