Predefined macros in c. This section describes the macros that are provided and the circumstances under which they are defined. For example, if we want Pre-defined C/C++ Compiler Macros The macros are found here: Standards Compilers Libraries Operating systems Architectures General guidelines are found here: Version normalization Feature macros Endianness Please send updates/corrections to predef-contribute. This macro is defined, with value 1, if the compiler’s target is a hosted environment. As you become proficient in using macros, you'll unlock new ways to write efficient and elegant C code. Explore various examples and best practices. Introduction C and C++ compilers automatically define certain macros that can be used to check for compiler or operating system features Macros (The C Preprocessor) 3 Macros ¶ A macro is a fragment of code which has been given a name. They differ mostly in what they look like when they are used. ) When writing portable C++ code you need to write conditional code that depends on compiler used or the OS for which the code is written. 31 KB Raw 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 C preprocessor The C preprocessor (CPP) is a text file processor that is used with C, C++ and other programming tools. C and C++ compilers automatically define certain macros that can be used to check for compiler or operating system features. You don't need to define them — they are automatically available in your program. The preprocessor provides for file inclusion (often header files), macro expansion, conditional compilation, and line control. The #ifdef and #ifndef directives let you include or skip parts of the code depending on whether a macro is defined. Typically, these macros represent numeric constants or string literals. 7. This is called conditional compilation, and it's useful for debugging or creating different versions of a program. Their names all start with double underscores. Learn about C macros, their usage, and how they can enhance your programming efficiency. bpf-predefined-macros. Introduction to Macros in C Language Suppose we are working on an application in C language and there is one value or an object or segment of code which we require so many times in our code then with the help of macros we can define it once and use it many times. See examples of predefined macros like __DATE__, __FILE__, __LINE__, and __TIME__. Standard Predefined Macros (The C Preprocessor) 3. This is useful when writing portable software. Older compilers may not provide all of them. A hosted environment provides the full facilities of the standard C library. c Code Blame 116 lines (104 loc) · 2. These macros are defined by the compiler and cannot be modified. The rest of the predefined macros are GNU C extensions. The Microsoft C/C++ compiler (MSVC) predefines certain preprocessor macros depending on the language (C or C++), the compilation target, and the chosen compiler options. __FILE__ This macro expands to the name of the current input file Aug 26, 2025 · Predefined macros are special macros that are already built into the C++ compiler. These two macros return the current date and time when the program was compiled. Here’s a typical case: May 7, 2024 · Macros have multiple types and there are some predefined macros as well. These pages lists various pre-defined compiler macros that can be used to identify standards, compilers, operating systems, hardware architectures, and even basic run-time libraries at compile-time. Many of them are only defined under certain circumstances. Sep 22, 2024 · Additionally, the predefined macros in C offer valuable information about the code and compilation process, aiding in debugging and context-aware programming. Jul 12, 2025 · According to C89 Standard, C programming language has following predefined macros: __LINE__ Macro: __LINE__ macro contains the current line number of the program in the compilation. Whenever the name is used, it is replaced by the contents of the macro. The macros are useful to create conditional C code. There are two kinds of macros. . Several object-like macros are predefined; you use them without supplying their definitions. The TASKING C compiler supports the predefined macros as defined in the table below. All C compilers provide a set of predefined macros that can be used in a C program. You may define any valid Guide to predefined macros in C++ compilers (gcc, clang, msvc etc. They fall into three classes: standard, common, and system-specific. 1 Standard Predefined Macros ¶ The standard predefined macros are specified by the relevant language standards, so they are available with all compilers that implement those standards. Object-like macros resemble data objects when used, function-like macros resemble function calls. Learn how to use C preprocessor directives to define macros, include header files, and perform conditional compilation. 6 days ago · Macros and its types in C की पूरी जानकारी हिंदी में। C Language में Macros क्या है, Types of Macros, Object-like Macro, Function-like Macro, Preprocessor Directives और Practical Examples के साथ समझें। The C++ compiler defines a number of preprocessing macros. slgor seuti cgrgv jln ityj esb xkk bwbz lzuf bbbyt