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

0 Members and 1 Guest are viewing this topic.

Offline 741

  • Frequent Contributor
  • **
  • Posts: 351
  • 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

  • Frequent Contributor
  • **
  • Posts: 829
  • 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”.
You are grounded! — said mom to pin 11 of an LM324 op-amp
Worth watching: Calling Bullshit — protect your friends and yourself from bullshit!
 

Online edavid

  • Super Contributor
  • ***
  • Posts: 3254
  • 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: 11174
  • 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

 



Advertise on the EEVblog Forum