当前位置:网站首页>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
cppThe magic number is defined in the file by using the global namespace with constants - Use enumeration to define magic numbers
边栏推荐
- pip install pyodbc : ERROR: Command errored out with exit status 1
- 【逆向初级】独树一帜
- Connect to LAN MySQL
- Huawei certified cloud computing hica
- 灵活报表v1.0(简单版)
- Automatic operation and maintenance sharp weapon ansible Playbook
- Redis quick start
- The most complete tcpdump and Wireshark packet capturing practice in the whole network
- Jetpack compose 1.1 release, based on kotlin's Android UI Toolkit
- [VNCTF 2022]ezmath wp
猜你喜欢

Development and practice of lightweight planning service tools

JUnit unit test

Connect to LAN MySQL

Wordcloud colormap color set and custom colors

关于Selenium启动Chrome浏览器闪退问题

04 products and promotion developed by individuals - data push tool

07 personal R & D products and promotion - human resources information management system

华为认证云计算HICA

全网最全tcpdump和Wireshark抓包实践

Uipath browser performs actions in the new tab
随机推荐
【逆向中级】跃跃欲试
mysql高級(索引,視圖,存儲過程,函數,修改密碼)
案例:检查空字段【注解+反射+自定义异常】
Wordcloud colormap color set and custom colors
Flexible report v1.0 (simple version)
TCP connection is more than communicating with TCP protocol
【逆向初级】独树一帜
MySQL Advanced (index, view, stored procedures, functions, Change password)
C# NanoFramework 点灯和按键 之 ESP32
04个人研发的产品及推广-数据推送工具
Virtual machine startup prompt probing EDD (edd=off to disable) error
数据仓库建模使用的模型以及分层介绍
List集合数据移除(List.subList.clear)
04 products and promotion developed by individuals - data push tool
Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘
CentOS7上Redis安装
Grafana 9 is officially released, which is easier to use and more cool!
Precipitated database operation class - version C (SQL Server)
Grafana 9 正式发布,更易用,更酷炫了!
Brush questions during summer vacation, ouch ouch