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缩进块的功能就好。

相关推荐
轩情吖8 分钟前
Qt常用控件之QSpinBox
开发语言·c++·qt·控件·桌面级开发·qspinbox·微调框
掘根9 分钟前
【Qt】输入类控件2——SpinBox,DateEdit,TimeEdit,Dial,Slider
开发语言·qt
wshzrf13 分钟前
【Java系列课程·Java学前须知】第3课 JDK,JVM,JRE的区别和优缺
java·开发语言·jvm
铅笔侠_小龙虾16 分钟前
JVM 深入研究 -- 详解class 文件
java·开发语言·jvm
Humbunklung18 分钟前
C# 使用应用RSA和ECC进行数字签名和签名验证
开发语言·c#·rsa·ecc
Larry_Yanan28 分钟前
QML学习笔记(十四)QML的自定义模块
开发语言·笔记·qt·学习·ui
练习时长一年36 分钟前
ApplicationContext接口实现(二)
java·开发语言
wdfk_prog1 小时前
[Linux]学习笔记系列 -- lib/sort.c 通用的排序库(Generic Sorting Library) 为内核提供标准的、高效的排序功能
linux·运维·c语言·笔记·stm32·学习·bug
灵性花火1 小时前
针对多工程情况下,Qwidget的ui文件的Stylesheet找不到图片的问题
开发语言·qt
shark_dev1 小时前
C/C++ 指针详解与各种指针定义
c语言·c++