What is a Macro Definition in C for C macro definitions?

Updated on technology 2024-02-09
5 answers
  1. Anonymous users2024-02-06

    These are not macro definitions, these are file containments.

    The macro defines a string like this: define identifier.

    include contains standard input/output libraries.

    include contains Windows libraries.

    include contains the time library.

  2. Anonymous users2024-02-05

    include contains header files, and some of the functions below these three instructions will use the functions in these three header files, and the header files are generally the declarations of the functions you want to use, which is equivalent to declaring the functions you want to use below.

  3. Anonymous users2024-02-04

    The macro definition is also known as macro substitution, macro substitution, or "macro" for short.

    is one of the three preprocessing functions provided by C.

    1. Macro names are generally capitalized.

    2. The use of macros can improve the versatility and legibility of the program, reduce inconsistencies, reduce input errors and facilitate modification. For example, array size is commonly defined by macros.

    3. Preprocessing is the processing before compilation, and one of the tasks of compilation work is syntax checking, and preprocessing does not do syntax checking.

    4. There is no semicolon at the end of the macro definition.

    5. The macro definition is written outside the curly braces of the function, and the scope is the program after it, usually at the beginning of the file.

    6. You can use the undef command to terminate the scope defined by the macro.

    7. Macro definitions can be nested.

    8. Strings" "Macros are never included in .

    9. Macro definition does not allocate memory, variable definition allocates memory.

  4. Anonymous users2024-02-03

    There are two types of macro definition usage in the C language.

    1. The definition of a macro without parameters is relatively simple, that is, a specified identifier is used to represent a string. Its general form is a "define identifier string", e.g. define e. This method allows users to replace a long string with a simple name.

    2. The macro definition with parameters is not only a simple string replacement, but also a parameter replacement. The general form of its definition is; define identifier (macro name) (parameter table) string, which contains the parameter specified in parentheses. For example, define s(a,b) a*b area=s(3.

  5. Anonymous users2024-02-02

    Function-like macros can be replaced in a more complex way than object-like macros.

    The functional macro sqr is compiled and populated with the program, thereforeFunctional macros can be used as long as there is a type of data that can be multiplied with the binocular operator *

    For function definition, each parameter needs to define its own data type, and the return value can only be of one type. In this regard, the function is more restrictive.

    Functions do some complex processing for us in obscurity, such as:

    Functional macros, on the other hand, do just macros and fill in programs, and do not do the above.

    According to the above characteristics,Functional macros may make the program run a little faster, but the program itself can become bloated

    Functional macros must be used with caution. For example, every time after sqr(a++)a++), the value of a will self-increment twice. Inadvertently an expression is executed twice, resulting in an unexpected result for the program, which we call macro***(side effect)

Related questions
9 answers2024-02-09

Scope. You static char *chh;

static char *ch1;Although the address pointed to by the two pointers does not change, have you ever wondered whether the memory address they point to has been released, char chc[10]; It's local, the function is out, the lifecycle is over, and you're trying to access it with a pointer in void times(). >>>More

4 answers2024-02-09

It's not very hard that the tail node next points to null. >>>More

9 answers2024-02-09

#include

int main(void) >>>More

6 answers2024-02-09

Understand the following rules: 1) Overloading an operator does not change the priority of the operator. >>>More

6 answers2024-02-09

I majored in computer science, and I was embarrassed when I first learned C language, but I also had some experience. >>>More