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

相关推荐
滴滴滴嘟嘟嘟.16 小时前
Qt动画功能学习
开发语言·qt·学习
福大大架构师每日一题16 小时前
go 1.25.1发布:重点修复net/http跨域保护安全漏洞(CVE-2025-47910)
开发语言·http·golang
Ophelia(秃头版16 小时前
经典设计模式:单例模式、工厂模式
java·开发语言·单例模式
Dear.爬虫17 小时前
Golang中逃逸现象, 变量“何时栈?何时堆?”
开发语言·后端·golang
编码浪子17 小时前
趣味学RUST基础篇(构建一个命令行程序2重构)
开发语言·重构·rust
echoarts18 小时前
MATLAB R2025a安装配置及使用教程(超详细保姆级教程)
开发语言·其他·matlab
阿方.91818 小时前
《数据结构全解析:栈(数组实现)》
java·开发语言·数据结构
CYRUS_STUDIO18 小时前
LLVM 不止能编译!自定义 Pass + 定制 clang 实现函数名加密
c语言·c++·llvm
CYRUS_STUDIO18 小时前
OLLVM 移植 LLVM 18 实战,轻松实现 C&C++ 代码混淆
c语言·c++·llvm
Dovis(誓平步青云)18 小时前
《探索C++11:现代语法的内存管理优化“性能指针”(下篇)》
开发语言·jvm·c++