当前位置:网站首页>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
边栏推荐
- Grafana 9 is officially released, which is easier to use and more cool!
- 03 products and promotion developed by individuals - plan service configurator v3.0
- How uipath determines that an object is null
- Concept and basic knowledge of network layering
- Jetpack compose 1.1 release, based on kotlin's Android UI Toolkit
- Wordcloud colormap color set and custom colors
- 数据仓库建模使用的模型以及分层介绍
- C version selenium operation chrome full screen mode display (F11)
- Solrcloud related commands
- 连接局域网MySql
猜你喜欢
Learn the wisdom of investment Masters
Selenium test of automatic answer runs directly in the browser, just like real users.
CTF逆向入门题——掷骰子
05 personal R & D products and promotion - data synchronization tool
02个人研发的产品及推广-短信平台
【逆向】脱壳后修复IAT并关闭ASLR
Solr appears write Lock, solrexception: could not get leader props in the log
List set data removal (list.sublist.clear)
Flink parsing (IV): recovery mechanism
Display picture of DataGridView cell in C WinForm
随机推荐
信息与网络安全期末复习(基于老师给的重点)
数据仓库建模使用的模型以及分层介绍
【ASM】字节码操作 ClassWriter 类介绍与使用
Essai de pénétration du Code à distance - essai du module b
Flink parsing (IV): recovery mechanism
Akamai 反混淆篇
[mmdetection] solves the installation problem
mysql 基本增删改查SQL语句
03个人研发的产品及推广-计划服务配置器V3.0
MySQL报错解决
Xin'an Second Edition: Chapter 25 mobile application security requirements analysis and security protection engineering learning notes
自动化运维利器ansible基础
pip install pyodbc : ERROR: Command errored out with exit status 1
连接局域网MySql
04 products and promotion developed by individuals - data push tool
vscode
MySQL error reporting solution
Integrated development management platform
EasyRE WriteUp
Akamai anti confusion