C:宏:编程风格:井号与define之间的空格

在这一篇中有提到,井号与define之间空格,可能导致搜索上的一些问题。

https://mzhan017.blog.csdn.net/article/details/135289451

今天看到有专门做这个空格的修改:

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fcf70d4114db9ff7923f5dfeb3fea6e2d623e5c2;hp=3f3822198993be18d4d9ccb1593eea274dbd2ba0

应该是为了阅读代码的方便性,因为如果不加空格会对代码阅读造成一定的困难;但是为什么不直接将整个#define都缩进呢?例如下面的一段

glibc/elf/dl-load.h

clike 复制代码
/* The right way to map in the shared library files is MAP_COPY, which
   makes a virtual copy of the data at the time of the mmap call; this
   guarantees the mapped pages will be consistent even if the file is
   overwritten.  Some losing VM systems like Linux's lack MAP_COPY.  All we
   get is MAP_PRIVATE, which copies each page when it is modified; this
   means if the file is overwritten, we may at some point get some pages
   from the new version after starting with pages from the old version.

   To make up for the lack and avoid the overwriting problem,
   what Linux does have is MAP_DENYWRITE.  This prevents anyone
   from modifying the file while we have it mapped.  */
#ifndef MAP_COPY
# ifdef MAP_DENYWRITE
#  define MAP_COPY      (MAP_PRIVATE | MAP_DENYWRITE)
# else
#  define MAP_COPY      MAP_PRIVATE
# endif
#endif

应个人的阅读爱好,其实只要养成一种阅读习惯,就可以,不管是前加空格还是后加空格,只要可用表示出if缩进块的功能就好。

相关推荐
yyy(十一月限定版)5 小时前
224redfg
c语言
2601_962885726 小时前
如何用 Python 自动识别股票的支撑位与压力位?
开发语言·python
爱吃奥利奥_wen6 小时前
面向对象三板斧:封装、继承、多态,到底在“装“什么、“承“什么、“变“什么?
开发语言·经验分享·c#
我可能是个假开发6 小时前
FTP Unicode 文件名导致 `550` 的问题分析与解决方案
java·开发语言·spring
小师兄吃牛肉7 小时前
C语言中的nullptr有必要吗
c语言·c++·算法
WL学习笔记8 小时前
日期类(C++)
开发语言·c++·日期类实现
谢亮_vipxieliang8 小时前
Go map与结构体的正确使用
开发语言·golang·哈希算法
H.莓飛8 小时前
【C++】命名空间、缺省参数、函数重载与引用
linux·开发语言·c++·visual studio
lhbweilai8 小时前
深挖FreeRTOS内核实现(三)
c语言·stm32·单片机
xxwl5859 小时前
数据结构知识点和代码实现总结(C语言实现)
c语言·开发语言·数据结构