I am a first year computer science student and my professor said #define
is banned in the industry standards along with #if
, #ifdef
, <
Macros can not be "banned". The statement is nonsense. Literally.
For example, section 7.5 Errors
of the C Standard requires the use of macros:
1 The header
defines several macros, all relating to the reporting of error conditions.
2 The macros are
EDOM EILSEQ ERANGE
which expand to integer constant expressions with type
int
, distinct positive values, and which are suitable for use in#if
preprocessing directives; anderrno
which expands to a modifiable lvalue that has type
int
and thread local storage duration, the value of which is set to a positive error number by several library functions. If a macro definition is suppressed in order to access an actual object, or a program defines an identifier with the nameerrno
, the behavior is undefined.
So, not only are macros a required part of C, in some cases not using them results in undefined behavior.