Why doesn't the compiler report a missing semicolon?

后端 未结 5 1002
夕颜
夕颜 2020-12-13 16:55

I have this simple program:

#include 

struct S
{
    int i;
};

void swap(struct S *a, struct S *b)
{
    struct S temp;
    temp = *a    /*          


        
5条回答
  •  温柔的废话
    2020-12-13 17:16

    There's a Polish movie titled "Nic Śmiesznego" ("Nothing Funny"). Here's an excerpt of relevant dialogue from a scene that shows exactly why the compiler developers may be a bit shy to proclaim such missing semicolons with reckless abandon.

    Director: What do you mean "this one"?! Are you saying that this object is in my field of view? Point it out with your finger, because I want to believe I'm dreaming.

    Adam: This, right here (points).

    Director: This? What is this?!

    Adam: What do you mean? It's a forest.

    Director: Can you tell me why the bloody hell would I need a forest?

    Adam: How come "bloody hell"? Here, in the screenplay, it says a forest, it says...

    Director: In the screenplay? Find it in this screenplay for me.

    Adam: Here: (reads) "When they came upon the crest of the road, in front of them appeared a forest"

    Director: Flip the page.

    Adam: Oh crap...

    Director: Read it for me.

    Adam: in front of them appeared a forest... of headstones.

    See, it's not generally possible to tell in advance that you really meant a forest and not a forest of headstones.

提交回复
热议问题