突出显示为关键字的宏:pascal [英] A macro highlighted as keyword: pascal

查看:45
本文介绍了突出显示为关键字的宏:pascal的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在查找 FunkyOverlayWindow ,我刚刚发现了一个非常有趣的声明:

While looking in the sample code for FunkyOverlayWindow, I just found a pretty interesting declaration:

pascal OSStatus MyHotKeyHandler(
    EventHandlerCallRef nextHandler,
    EventRef theEvent,
    void *userData
);

在这里, pascal 作为关键字突出显示(标准Xcode配色中为粉红色).但是我只是发现它是一个宏,有趣的是,在文件CarbonCore/ConditionalMacros.h中将其定义为:

Here, pascal is highlighted as a keyword (pink in standard Xcode color scheme). But I just found it's a macro, interestingly enough defined in file CarbonCore/ConditionalMacros.h as:

#define pascal

那么,它应该(或曾经)做什么?也许它在过去有特殊用途?

So, what is (or was) it supposed to do? Maybe it had some special use in the past?

尽管此讨论可能不适用于此处,但有趣的是,如果这与答案相关,那么为什么苹果仍在使用Carbon还是很有趣的.我没有Carbon的经验,但是这段代码似乎设置了一个键盘事件处理程序,这使我想知道是否比Cocoa方法有任何优势.碳会永远不会被完全清除吗?

While this discussion might not be well suited here, it would be interesting to know why Apple still using Carbon if this relates to the answer. I have no experience in Carbon, but this code appears to set a keyboard event handler which makes me wonder if there are any advantages over the Cocoa approach. Won't Carbon be ever removed completely?

推荐答案

在68k Classic Mac OS运行时下(例如,在PowerPC x86之前),C和Pascal使用了不同的调用约定,因此C使用Pascal约定(包括大多数操作系统)调用库时,应用程序必须声明适当的约定.该宏是在同时代的编译器(例如MPW,Metrowerks,Think C)中实现的.

Under the 68k Classic Mac OS runtime (e.g, before PowerPC or x86), C and Pascal used different calling conventions, so C applications had to declare the appropriate convention when calling into libraries using the Pascal conventions (including most of the operating system). The macro was implemented in contemporaneous compilers (e.g, MPW, Metrowerks, Think C).

在所有较新的运行时和所有现代编译器中,都不再识别该关键字,因此 ConditionalMacros.h 标头将其定义了.该文件中有几条评论可能会帮助您解释更多内容-如果您是游戏者,请仔细阅读.

In all newer runtimes, and in all modern compilers, the keyword is no longer recognized, so the ConditionalMacros.h header defines it away. There are a few comments in that file which may help explain a bit more -- read through it, if you're game.

这篇关于突出显示为关键字的宏:pascal的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆