Question about #define

Asked 2 years ago, Updated 2 years ago, 79 views

Due to security errors

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>

You write it at the beginning of the chords like this. By the way,

#include <iostream>
#include <cstring>
#define _CRT_SECURE_NO_WARNINGS

I couldn't do it like this Isn't it because it's done in preprocessing anyway, so the order doesn't it? Actually, I don't know.

preprocessor

2022-09-20 11:40

1 Answers

Preprocessing is processed from top to bottom.

Simultaneously, it doesn't work at once, but it goes one line at a time.

Therefore, if #define_CRT_SECURE_NO_WARNINGS is at the top, iostream and casting are already defined when _CRT_SECURE_NO_WARNINGS are added. When #define_CRT_SECURE_NO_WARNINGS is added at the end, iostream and constring are added, _CRT_SECURE_NO_WARNINGS is undefined.

The two actions can be significantly different in meaning.

Therefore, such preprocessing macros are usually defined in project properties.


2022-09-20 11:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.