当前位置:网站首页>The art of Engineering (1): try to package things that do not need to be exposed
The art of Engineering (1): try to package things that do not need to be exposed
2022-07-06 17:38:00 【Wzzzzzzx】
#ifndef _TEST_H_
#define _TEST_H_
#define SUCCESS 1
/**
* do Something
*/
#endif // _TEST_H_
This is a very common header file , We define a macro in it . According to past experience , Defining macros in header files is a common operation , But in fact, there is a security risk here .
Here we give a principle , namely :
For things that don't need to be known to the outside world , Should find ways to hide it
The reason is the same as the encapsulation in the object-oriented idea , Expose the interface to the outside world , The outside world may make unnecessary modifications . Besides , There may also be conflicts with macros defined by others .
The solutions are as follows :
- Define the macro here in the implementation file
- stay
cpp
The magic number is defined in the file by using the global namespace with constants - Use enumeration to define magic numbers
边栏推荐
- Kali2021 installation and basic configuration
- Integrated development management platform
- 集成开发管理平台
- Selenium test of automatic answer runs directly in the browser, just like real users.
- 03 products and promotion developed by individuals - plan service configurator v3.0
- Openharmony developer documentation open source project
- Automatic operation and maintenance sharp weapon ansible Playbook
- Shawshank's sense of redemption
- 华为认证云计算HICA
- connection reset by peer
猜你喜欢
网络分层概念及基本知识
05 personal R & D products and promotion - data synchronization tool
[introduction to MySQL] third, common data types in MySQL
03 products and promotion developed by individuals - plan service configurator v3.0
06 products and promotion developed by individuals - code statistical tools
yarn : 无法加载文件 D:\ProgramFiles\nodejs\yarn.ps1,因为在此系统上禁止运行脚本
pip install pyodbc : ERROR: Command errored out with exit status 1
关于Selenium启动Chrome浏览器闪退问题
Selenium test of automatic answer runs directly in the browser, just like real users.
Solr appears write Lock, solrexception: could not get leader props in the log
随机推荐
当前系统缺少NTFS格式转换器(convert.exe)
Interpretation of Flink source code (II): Interpretation of jobgraph source code
Essai de pénétration du Code à distance - essai du module b
MySQL basic addition, deletion, modification and query of SQL statements
【逆向初级】独树一帜
mysql高级(索引,视图,存储过程,函数,修改密码)
C#WinForm中的dataGridView滚动条定位
The most complete tcpdump and Wireshark packet capturing practice in the whole network
【MySQL入门】第一话 · 初入“数据库”大陆
全网最全tcpdump和Wireshark抓包实践
灵活报表v1.0(简单版)
【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias
Precipitated database operation class - version C (SQL Server)
MySQL Advanced (index, view, stored procedures, functions, Change password)
connection reset by peer
分布式(一致性协议)之领导人选举( DotNext.Net.Cluster 实现Raft 选举 )
Flink 解析(一):基础概念解析
[VNCTF 2022]ezmath wp
C version selenium operation chrome full screen mode display (F11)
连接局域网MySql