answersLogoWhite

0

Preprocessor: All the preprocessor commands written in a high level language are processed by the preprocessor before compiler takes over.

Example: "#define MAX_ROWS 10"

Preprocessor finds all the places and replaces MAX_ROWS with 10 in the files of the project.

Compiler: This software, converts the code written in high-level language into object file. Compiler converts all the files of a given project at once.

User Avatar

Wiki User

∙ 16y ago
User Avatar

What else can I help you with?

Continue Learning about Engineering

How do you implement c program for conditional compilation?

Conditional compilation is achieve through preprocessor directives. First, define the preprocessor symbols upon which conditional compilation depends, then test them using #if and #else preprocessor directives. A #endif directive indicates the end of the nearest enclosing conditional block, thus conditional blocks may be nested. The following example demonstrates how we can conditionally define debug or production code based upon the absence or existence of the NDEBUG symbol: #ifdef NDEBUG /* all C code within this block is compiled when NDEBUG is defined (production code) */ #else /* all C code within this block is compiled when NDEBUG is not defined (debug code) */ #endif Note that the NDEBUG symbol is typically defined via the command line, however symbols can also be defined or undefined via the source using the #define and #undefine directives. For instance, header files typically require guards to protect against being included more than once in a compilation and preprocessor directives provide the conventional means of ensuring that is the case: // myheader.h #ifndef _MYHEADER_H_ #define _MYHEADER_H_ // all header code goes here... #endif By convention, preprocessing symbols (macros) are defined with all uppercase and are intentionally ugly to avoid any confusion with C identifiers. Header guards must be unique to each header thus they are typically based upon the header file name itself.


What is the syntax of writing a header file?

A header file in C or C++ typically has a .h extension and contains declarations for functions, macros, constants, and data types. The syntax includes include guards to prevent multiple inclusions, which are implemented using #ifndef, #define, and #endif preprocessor directives. For example: #ifndef MY_HEADER_H #define MY_HEADER_H void myFunction(); #endif // MY_HEADER_H This structure ensures that the contents of the header file are included only once in a compilation unit.


What Java header file meaning?

Source code written in Java is simple. There is no preprocessor, no #define and related capabilities, no typedef, and absent those features, no longer any need for header files. Instead of header files, Java language source files provide the declarations of other classes and their methods.


What are preprocessor directive?

Preprocessor directives are used to mark code that is specific to a particular compiler and thus to a specific machine architecture. In this way, programmers can write cross-platform code in the same source and let the compiler decide which parts of the source to compile and which to ignore. In reality, the compiler never actually sees the preprocessor directives since the preprocessor creates new files containing only the code that is to be compiled. Hence the preprocessor is often called the precompiler. Normally, the intermediate source files are deleted as they are compiled, however your development environment should contain an option that allows you to view these files so you can see what the compiler actually works with. In C and C++, all preprocessor directives have a leading # symbol, such as #include and #define. #include is by far the most common preprocessor directive. When the precompiler encounters a #include statement, the named header file is essentially copy/pasted in place of the directive. However, all header files should also contain #ifndef header guards to ensure headers are only included once per compilation and these have to be preprocessed as well. Macro definitions are also preprocessed, replacing all instances of the macro symbol with the definition. Macro functions are also inline expanded but since the compiler only sees the expanded code, never the macro itself, the compiler cannot help you debug errant macros. This is why non-trivial macro functions are best avoided.


What is a preprocessor in c programming?

Preprocessor instructions are used to modify the compiler's perspective of the source code during the parsing phase, before the compilation phase. The most common preprocessor directives are "include" (place the source code from another file into the current file's parse point), "pragma" (change the compiler's flags), and "define" (define a compile-time constant). Other uses are conditional compilation instructions, such as using one algorithm for a certain platform, and a different one for another platform. Preprocessor directives never appear in the final executable code directly, but instead influence how the rest of the source code will be compiled.

Related Questions

What is the difference between the header file and the preprocessor directive in programming language cpp?

pata nhn


Does header contains preprocessor directive?

Yes, it often does.


How do you implement c program for conditional compilation?

Conditional compilation is achieve through preprocessor directives. First, define the preprocessor symbols upon which conditional compilation depends, then test them using #if and #else preprocessor directives. A #endif directive indicates the end of the nearest enclosing conditional block, thus conditional blocks may be nested. The following example demonstrates how we can conditionally define debug or production code based upon the absence or existence of the NDEBUG symbol: #ifdef NDEBUG /* all C code within this block is compiled when NDEBUG is defined (production code) */ #else /* all C code within this block is compiled when NDEBUG is not defined (debug code) */ #endif Note that the NDEBUG symbol is typically defined via the command line, however symbols can also be defined or undefined via the source using the #define and #undefine directives. For instance, header files typically require guards to protect against being included more than once in a compilation and preprocessor directives provide the conventional means of ensuring that is the case: // myheader.h #ifndef _MYHEADER_H_ #define _MYHEADER_H_ // all header code goes here... #endif By convention, preprocessing symbols (macros) are defined with all uppercase and are intentionally ugly to avoid any confusion with C identifiers. Header guards must be unique to each header thus they are typically based upon the header file name itself.


What is the difference between a header and a title on a report?

what is the difference between titles and headings in general.


What is the syntax of writing a header file?

A header file in C or C++ typically has a .h extension and contains declarations for functions, macros, constants, and data types. The syntax includes include guards to prevent multiple inclusions, which are implemented using #ifndef, #define, and #endif preprocessor directives. For example: #ifndef MY_HEADER_H #define MY_HEADER_H void myFunction(); #endif // MY_HEADER_H This structure ensures that the contents of the header file are included only once in a compilation unit.


How do you include classes and structures in header files in c plus plus?

Classes and structures can be put in a header file the same way you would use them in a main program; the only difference is that they are placed in a separate file, called a header file. Then, after creating a new file, include that new file with the definition by the use of the preprocessor #include statement.


What is the difference between a report header and a page header in access?

The page header repeats on every page. The report header is just on the first page.


What pre-processer will do in c language?

The preprocessor (or precompiler) processes all the preprocessor directives and macro definitions within your source files. In other words it creates modified source files where all directives and macros are completely stripped out and replaced by their respective definitions. For instance, each #include statement in your source inserts the named header just as if you'd copy/pasted that entire header into your source. However, prior to insertion, the header itself must be preprocessed, thus it is the modified code that is physically inserted. Once inserted, the #include directive is removed from the modified source. Since the compiler works with modified source files (intermediate sources), the compiler never sees your macro definitions and therefore cannot help you debug them. A macro is a primitive text replacement system so if this creates invalid code, a compiler error occurs but the compiler cannot tell you where that error originated because it is processing code that does not exist in your source.


How do you create a user defined header file?

Header files are not much different from usual cpp files. There are basically two different things. It's file extension: you need to choose "header file" when you create it or save as .h file. Second is header files do not have main() function. When you are done with you header file do not forger to include it in your project by writing preprocessor directive:#include "your_header_file.h"


What Java header file meaning?

Source code written in Java is simple. There is no preprocessor, no #define and related capabilities, no typedef, and absent those features, no longer any need for header files. Instead of header files, Java language source files provide the declarations of other classes and their methods.


What is the difference between System Network Architecture and Open System Interconnections layers?

osi add header at each layer but SNA add header at bottom layers


What are preprocessor directive?

Preprocessor directives are used to mark code that is specific to a particular compiler and thus to a specific machine architecture. In this way, programmers can write cross-platform code in the same source and let the compiler decide which parts of the source to compile and which to ignore. In reality, the compiler never actually sees the preprocessor directives since the preprocessor creates new files containing only the code that is to be compiled. Hence the preprocessor is often called the precompiler. Normally, the intermediate source files are deleted as they are compiled, however your development environment should contain an option that allows you to view these files so you can see what the compiler actually works with. In C and C++, all preprocessor directives have a leading # symbol, such as #include and #define. #include is by far the most common preprocessor directive. When the precompiler encounters a #include statement, the named header file is essentially copy/pasted in place of the directive. However, all header files should also contain #ifndef header guards to ensure headers are only included once per compilation and these have to be preprocessed as well. Macro definitions are also preprocessed, replacing all instances of the macro symbol with the definition. Macro functions are also inline expanded but since the compiler only sees the expanded code, never the macro itself, the compiler cannot help you debug errant macros. This is why non-trivial macro functions are best avoided.