anselmschueler,
@anselmschueler@ieji.de avatar

In my opinion, C’s declaration-follows-usage is in and of itself not bad, merely idiosyncratic. Where it gets super bad is when you declare the identifier via the declarator and assign to the identifier not via the declarator in the same line.

#c #programming

glaskows,
@glaskows@mastodon.gamedev.place avatar

@anselmschueler Only if you make the assumption * is not part of the type (which it is).
In your example,
int *x_ptr; // int * describes x_ptr

anselmschueler,
@anselmschueler@ieji.de avatar

@glaskows As I understand it: int * is the type of x_ptr, but int is the type of *x_ptr. The declaration, syntactically, is not the type int * juxtaposed with x_ptr, but the type int juxtaposed with the declarator *x_ptr. This is most clearly demonstrated by multiple declarations with one type: int *a, b means a is a pointer, b isn’t. The type int * is an independent construction formed by omitting the identifier from the declarator.

glaskows,
@glaskows@mastodon.gamedev.place avatar

@anselmschueler I see the multiple declaration as broken syntax. If you omit that, then everything fits together.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • programming
  • DreamBathrooms
  • mdbf
  • ngwrru68w68
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • osvaldo12
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • InstantRegret
  • tacticalgear
  • provamag3
  • ethstaker
  • cisconetworking
  • modclub
  • tester
  • GTA5RPClips
  • cubers
  • everett
  • normalnudes
  • megavids
  • Leos
  • anitta
  • JUstTest
  • lostlight
  • All magazines