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

相关推荐
pusue_the_sun18 分钟前
数据结构——栈和队列oj练习
c语言·数据结构·算法··队列
Dontla1 小时前
Makefile介绍(Makefile教程)(C/C++编译构建、自动化构建工具)
c语言·c++·自动化
后台开发者Ethan1 小时前
Python需要了解的一些知识
开发语言·人工智能·python
奶黄小甜包1 小时前
C语言零基础第18讲:自定义类型—结构体
c语言·数据结构·笔记·学习
一支闲人1 小时前
C语言相关简单数据结构:双向链表
c语言·数据结构·链表·基础知识·适用于新手小白
常利兵2 小时前
Kotlin作用域函数全解:run/with/apply/let/also与this/it的魔法对决
android·开发语言·kotlin
幼稚园的山代王2 小时前
Kotlin-基础语法练习一
android·开发语言·kotlin
重生成为编程大王2 小时前
Java ConcurrentHashMap 深度解析
java·开发语言
John.Lewis2 小时前
数据结构初阶(19)外排序·文件归并排序的实现
c语言·数据结构·排序算法
John.Lewis2 小时前
数据结构初阶(16)排序算法——归并排序
c语言·数据结构·排序算法