Author Topic: Checking specifier distribution over variable list declaration using cdecl.org  (Read 499 times)

0 Members and 1 Guest are viewing this topic.

Offline 741Topic starter

  • Frequent Contributor
  • **
  • Posts: 386
  • Country: gb
    • Circuit & PCB Design (small PCB quantities OK)
I typed this into the box at https://cdecl.org/

static int a, b;

It reports "syntax error". Where is my mistake - is this really illegal C code, or maybe this is not what the cdecl site is for?

Note: I'd actually wanted to double-check a point about the way specifiers distribute over comma-separated variable declarations.
The link I was looking at which relates to this point is here https://stackoverflow.com/questions/55786769/are-all-keywords-distributed-for-comma-separated-variable-definitions

« Last Edit: June 26, 2022, 05:23:39 pm by 741 »
 

Offline golden_labels

  • Super Contributor
  • ***
  • Posts: 1208
  • Country: pl
The code is perfectly valid C.

The webapp seems to be, however, a kind of a toy. A contraption meant for entertainment purposes only. Or, if anything beyond that, meant to translate particular subset of complicated C declarations to something “more understandable”.
People imagine AI as T1000. What we got so far is glorified T9.
 

Offline edavid

  • Super Contributor
  • ***
  • Posts: 3381
  • Country: us
The cdecl site is intended to explain declarations, and I find it helpful for that.  It is not a full C interpreter.  It can only parse a single declaration, not a list.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14447
  • Country: fr
The cdecl site is intended to explain declarations, and I find it helpful for that.  It is not a full C interpreter.  It can only parse a single declaration, not a list.

Yes, indeed. It works perfectly fine for single declarations and is not meant for anything more than this.
It's not a "toy". It can be useful not just for understanding "complex" declarations as a human, but also to check your own parser/analyzer, if you're implementing one, against tricky declarations. I did use it at some point for that.

The additional point of this site is to show how absurd C declarations can be, if you want to have a laugh, or if you are considering designing a new language and get convinced that the C syntax is flawed for humans.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf