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

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

相关推荐

  1. C编程风格define之间空格

    2024-01-02 11:48:04       59 阅读
  2. C 练习实例49-#define命令练习3

    2024-01-02 11:48:04       59 阅读
  3. C 练习实例46-#define命令练习

    2024-01-02 11:48:04       57 阅读
  4. #if defined(WEBRTC_USE) webrtc.a机制

    2024-01-02 11:48:04       19 阅读
  5. Boost.PythonBOOST_TEST_EQ示例编程

    2024-01-02 11:48:04       56 阅读
  6. C++C语言之间区别

    2024-01-02 11:48:04       44 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-02 11:48:04       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-02 11:48:04       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-02 11:48:04       82 阅读
  4. Python语言-面向对象

    2024-01-02 11:48:04       91 阅读

热门阅读

  1. 将jupyter转换为python文件

    2024-01-02 11:48:04       58 阅读
  2. LeetCode 20. 有效的括号

    2024-01-02 11:48:04       56 阅读
  3. Android 10.0 截屏流程

    2024-01-02 11:48:04       47 阅读
  4. Atlas Hook 导入 Hive 元数据

    2024-01-02 11:48:04       52 阅读
  5. KVM虚拟机部署K8S重启后/etc/hosts内容丢失

    2024-01-02 11:48:04       57 阅读
  6. 深入理解@Resource与@Autowired:用法与区别解析

    2024-01-02 11:48:04       54 阅读
  7. JDK下载地址

    2024-01-02 11:48:04       69 阅读
  8. GRU算法

    GRU算法

    2024-01-02 11:48:04      125 阅读