“pragma”这个词在哪里?来自?

发布于 2024-09-25 04:30:48 字数 78 浏览 0 评论 0原文

所以我知道 pragma 是什么,以及它的用途,但是这个词本身的含义是什么?我在代码中多次使用过它,但我从来不知道这个词的实际含义或代表什么。

So I know what pragma is, and what it's used for, but what is the meaning of the word itself? I've used it many times in code, but I never really knew what the word actually means or stands for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

梦明 2024-10-02 04:30:48

根据美国政府拥有的(!)文件描述了 Ada 的设计:设计的基本原理
Ada® 编程语言

pragma(来自希腊语,意思是
action) 用于指导动作
编译器以特定方式,
但对语义没有影响
一个程序(一般而言)。

我喜欢那里的(最后一个警告)...

这与在线希腊语词典很好地交叉引用(例如,Martin York)说pragma(πράγμα,如asveikau对原始问题的评论)意思

  1. 已完成的事情、行为、已完成的事实
  2. 已完成或正在完成的事情
    1. 规格。生意,商业交易
  3. ,事情,问题,事件
    1. 规格。从法医意义上来说,是法律、案件、诉讼中的问题
  4. 是或存在的,一个事物

似乎理解的关键是单词“行动”而不是“信息”。

According to a US Government-owned(!) document describing the design of Ada: Rationale for the Design of the
Ada® Programming Language
:

A pragma (from the Greek word meaning
action) is used to direct the actions
of the compiler in particular ways,
but has no effect on the semantics of
a program (in general).

I like the (last caveat) there...

This cross references well with on-line greek dictionaries (e.g. as quoted by Martin York) that say pragma (πράγμα, as commented on the original question by asveikau) means:

  1. that which has been done, a deed, an accomplished fact
  2. what is done or being accomplished
    1. spec. business, a commercial transaction
  3. a matter, question, affair
    1. spec. in a forensic sense, a matter at law, case, suit
  4. that which is or exists, a thing

Seems the key to understanding is the word action rather than information.

呆橘 2024-10-02 04:30:48

在数学和逻辑中,pragma 是一个给定的事实,是随后的论证、问题或证明的先决条件。

In mathematics and logic, a pragma is a given, a fact, a prerequisite to the argument, problem, or proof which follows.

萌辣 2024-10-02 04:30:48

直接从 Wikipedia(编程)中提取:

在 Ada 中,编译器指令称为 pragmas(“实用信息”的缩写)。

虽然它没有明确针对 C,但这应该可以回答您的问题。然而,正如 TJ 指出的那样,这条信息没有给出有效的来源。

Pulled right from Wikipedia(programming):

In Ada, compiler directives are called pragmas (short for "pragmatic information").

While it's not explicitly for C, this should answer your question anyway. However, as T.J. pointed out, there is no valid source given for this piece of information.

巷雨优美回忆 2024-10-02 04:30:48

来自古希腊语:

pragma:完成的事情,事实

与所有令人讨厌的事情一样,有人为了自己的利益而试图变得太聪明。不幸的是,我们其他人已经失去了它的原始含义(除非你有谷歌和方便的拉丁语/希腊语到英语词典)。

http://www.studylight.org/lex/grk/view.cgi ?number=4229
http://www.bibletools.org/index .cfm/fuseaction/Lexicon.show/ID/G4229/pragma.htm

原文(这就是上面页面所说的,但我没有那本书的副本):

塞耶和史密斯。 “Pragma 的希腊词典条目”。 《新约希腊语词典》。

From the ancient Greek:

pragma: a thing done, a fact

As with all things geeky, somebody was trying to be way too clever for their own good. Unfortunately its original meaning becomes lost to the rest of us (unless you have Google and a Latin/Greek to English dictionary handy).

http://www.studylight.org/lex/grk/view.cgi?number=4229
http://www.bibletools.org/index.cfm/fuseaction/Lexicon.show/ID/G4229/pragma.htm

Original (that is what the above page says, but I don't have a copy of that book):

Thayer and Smith. "Greek Lexicon entry for Pragma". "The New Testament Greek Lexicon".

风柔一江水 2024-10-02 04:30:48

编程语言 Ada 很可能是第一个使用 pragma 来指定预处理器指令的编译器。该词被用作“实用信息”的缩写形式。

在设计 C 编程语言时,它最初并没有 pragma 指令,但很快就被添加到规范中以支持自定义编译器功能。 (即 intel C++ 编译器的#pragma optimization_level)

从那时起,许多语言都以某种形式实现了 pragma,包括 C#,但它们通常仅限于构建时警告和优化提示。

在非标准 C 和 C++ 中,最常见和最有用的编译指示之一是 #pragma Once用于指定一个文件只能包含一次。

The programming language Ada was quite possibly the first compiler to use pragma to specify preprocessor directives. The word was used as a shortened form of "pragmatic information"

When the C programming language was designed it didn't initially have pragma directives, but was quickly added to the specification to support custom compiler features. (ie. #pragma optimization_level for the intel C++ compiler)

Since then many languages have implemented pragma in some form or another, including C#, but they are often limited to build time warnings and optimization hints.

One of the most common and useful pragmas, in non-standard C and C++, is #pragma once used to specify that a file should only be included once.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文