What's the difference between parenthesis $() and curly bracket ${} syntax in Makefile?

前端 未结 6 415
长发绾君心
长发绾君心 2020-12-12 19:48

Is there any differences in invoking variables with syntax ${var} and $(var)? For instance, in the way the variable will be expanded or anything?

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-12 20:34

    Actually, it seems to be fairly different:

    , = ,
    list = a,b,c
    $(info $(subst $(,),-,$(list))_EOL)
    $(info $(subst ${,},-,$(list))_EOL)
    

    outputs

    a-b-c_EOL
    md/init-profile.md:4: *** unterminated variable reference. Stop.
    

    But so far I only found this difference when the variable name into ${...} contains itself a comma. I first thought ${...} was expanding the comma not as part as the value, but it turns out i'm not able to hack it this way. I still don't understand this... If anyone had an explanation, I'd be happy to know !

提交回复
热议问题