Why is FILE all-caps as in FILE*? [closed]

痞子三分冷 提交于 2019-11-30 08:55:53

问题


This just seems odd to me, most other things are lower case.

Is there some historical reason?


回答1:


It's a macro. Macros have historically had all caps in C. Unfortunately recent trends appear to have broken that fact.

Small history lesson: Also, FILE was an io buffer abstraction in UNIX v7 libc stdio. A FILE doesn't necessarily represent a physical file, just something that can do block IO. Source:

http://www.bsdlover.cn/study/UnixTree/V7/usr/include/stdio.h.html

"file" was already defined by the kernel as well:

http://www.bsdlover.cn/study/UnixTree/V7/usr/include/sys/file.h.html

As someone else said here it's probably a typedef now, but I don't think C had typedefs back in '79 as it only just had structs. Then again I wasn't born then so... :)




回答2:


It's all caps almost certainly because at least originally it was a macro. Nowadays, chances are pretty good that it's a typedef instead, but nobody changed the name to boot (and doing so would be a pretty lousy idea).



来源:https://stackoverflow.com/questions/6949192/why-is-file-all-caps-as-in-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!