开发者

Why are compiler specific directives called pragmas? [duplicate]

开发者 https://www.devze.com 2023-02-08 09:54 出处:网络
This question already has answers he开发者_StackOverflowre: Closed 12 years ago. Possible Duplicate:
This question already has answers he开发者_StackOverflowre: Closed 12 years ago.

Possible Duplicate:

Where does the word “pragma” come from?

I know that pragma commands are used to pass compiler specific directives to a compiler implementation, but why was the keyword pragma chosen? What is its etymology? Most language keywords are taken from real words, but pragma seems only to be defined within the context of programming.


I don't know exactly what the thought processes were behind it, but "pragma" comes from the ancient Greek word πραγμα, which means something like "action". It's also the root of the English words "pragmatic" and "practical". In other words, a #pragma directive is an action that the compiler should take, but it's also "pragmatic" and "practical", i.e., the sort of practical, pragmatic violation of the purity of the standard that you kind of need in the real world.

(I suppose this off-the-cuff etymology is close enough? Kinda makes sense to me, at any rate.)

0

精彩评论

暂无评论...
验证码 换一张
取 消