Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (EternallyCurious, Quad, vicknick), 700 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: [help] Passable / Polygon Flags [Re: DLively] #443740
07/23/14 19:15
07/23/14 19:15
Joined: May 2014
Posts: 179
The lit part of the Truth
C
CyberGhost Offline
Member
CyberGhost  Offline
Member
C

Joined: May 2014
Posts: 179
The lit part of the Truth
Oh ,man! Now I understood! I was just seeing the defines for the flags and was like 'WTF? WHAT IS > ? What is...etc.'

Btw. what is 'obj->' ? I mean what is -> ?

Last edited by CyberGhost; 07/23/14 19:24.

Nothing to say ....
Re: [help] Passable / Polygon Flags [Re: CyberGhost] #443741
07/23/14 19:16
07/23/14 19:16
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
afaik it's just like '.'

you.x
you->x


POTATO-MAN saves the day! - Random
Re: [help] Passable / Polygon Flags [Re: Kartoffel] #443742
07/23/14 20:06
07/23/14 20:06
Joined: Nov 2011
Posts: 274
de
lemming Offline
Member
lemming  Offline
Member

Joined: Nov 2011
Posts: 274
de
You use obj->x when obj is a pointer.

So like:
Code:
typedef struct mystruct {
  var val1;
  var val2;
} mystruct;

mystruct obj1;
mystruct* obj2 = sys_malloc(sizeof(mystruct));

obj1.val1 = 10;
obj2->val1 = 20;   // << Because obj2 is a pointer you use the arrow



LiteC does an automatic ->/. conversion. It's nice at the beginning but will screw everything when you advance.

Re: [help] Passable / Polygon Flags [Re: lemming] #443744
07/23/14 21:11
07/23/14 21:11
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Yes, -> and . are both for member access, and . is for objects and -> is for pointers.

That doesn't explain why that is there though. Kids, gather around!

The reason we have this confusing stuff and carry it around to this day is because of bearded guy called Dennis Ritchie. He wrote the C Reference Manual. And is the father of C. And UNIX. And he did other stuff as well.

What Dennis Ritchie made and called C is far away form what we call C nowadays (and thank god for that). The C Reference Manual, CRM, had quirky definition for structs and their members, like seriously quirky. A struct member defined a global offset for the translation unit it occurred in, for example, take the following struct;

Code:
struct foo
{
   int a;
   int b;
   int c;
};



c would afterwards be a globally defined offset of 8, because it was at the 8th byte offset of the struct foo. Similar, a would have a defined offset of 0. And now you could do fun things like this:

Code:
int x;
x.b = 24;



It did exactly what no sane person would expect it to do: Write 24 at offset 4 of the integer x. So _after_ the integer.

Only issue, it didn't work with addresses, so it didn't work on pointers. Dereferencing the pointer first didn't work either, because the reason it doesn't work with pointers is also the reason the expression (*bar) was illegal because it simply requires an lvalue operand.

The solution was the -> operator, which didn't care if it was an lvalue or an rvalue, treated everything as an address, applied the offset, dereferenced it and then wrote the value you wanted into it. Example:
Code:
1024->b = 5; // Writes 5 to address 1028

int x = 4;
x->c = 42; // Writes 42 into 12



Yes, that doesn't make any sense. But, remember, b and c were globally defined offsets, and -> treated everything as address.

And because that's batshit insane, when Ken Thompson joined Dennis and they both made K&R C, they threw away this nonsense altogether. Under K&R C, this global offset stuff was gone, and the -> operator became equivalent to (*x).foo

And that's why both are still there, the -> operator also dereferences the pointer, in addition to what the . operator does. And that's why Ken Thompson got mad pussy and Dennis Ritchie is known as that bearded guy who wrote the CRM.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: [help] Passable / Polygon Flags [Re: WretchedSid] #443757
07/23/14 23:20
07/23/14 23:20
Joined: May 2014
Posts: 179
The lit part of the Truth
C
CyberGhost Offline
Member
CyberGhost  Offline
Member
C

Joined: May 2014
Posts: 179
The lit part of the Truth
Ok, thanks.


Nothing to say ....
Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1