473,396 Members | 1,678 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How about preprocessor usage in C....?

13
Hi everyone,
i wanna kno bout the preprocessor usage in c... i m a beginner for this, so experts you can judge bout it.thank u
May 2 '08 #1
3 1350
JosAH
11,448 Expert 8TB
Hi everyone,
i wanna kno bout the preprocessor usage in c... i m a beginner for this, so experts you can judge bout it.thank u
What do you want to know about it exactly? (don't say: "how it works" please).
A preprocessor defines macros and rewrites text in which macros are present
including optional parameters. Note that a macro under expansion (rewriting)
is not being expanded further to avoid recursive behaviour. The preprocessor
properly tokenizes a piece of text for the compiler.

kind regards,

Jos
May 2 '08 #2
keane
13
What do you want to know about it exactly? (don't say: "how it works" please).
A preprocessor defines macros and rewrites text in which macros are present
including optional parameters. Note that a macro under expansion (rewriting)
is not being expanded further to avoid recursive behaviour. The preprocessor
properly tokenizes a piece of text for the compiler.

kind regards,

Jos
Thank u, i dont need any technical explanation just i wanna kno bout where preprocessor would be more helpful... that means which kinda applications or programs.... Is it really a most effective topic
May 2 '08 #3
JosAH
11,448 Expert 8TB
Thank u, i dont need any technical explanation just i wanna kno bout where preprocessor would be more helpful... that means which kinda applications or programs.... Is it really a most effective topic
Well, basically using a preprocessor should improve readability of the code and
should help you in typing consistent code on a very basic level. You can define
macros that you can use throughout your code. e.g. the following (sloppy) macro
is a shorthand for the maximum value of two values x and y:

Expand|Select|Wrap|Line Numbers
  1. #define MAX(x, y) (((x)>(y))?(x):(y))
  2.  
... so instead of typing (or reading!) all those nasty brackets and magic expressions
you can simply do:

Expand|Select|Wrap|Line Numbers
  1. int max= MAX(a, b);
  2.  
But note that this macro (as well as many macros) has a flaw, i.e. it evaluates
the value of the maximum twice and macros hide those facts. More modern
languages have other solutions instead of preprocessor macros for that.

kind regards,

Jos
May 2 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

205
by: Jeremy Siek | last post by:
CALL FOR PAPERS/PARTICIPATION C++, Boost, and the Future of C++ Libraries Workshop at OOPSLA October 24-28, 2004 Vancouver, British Columbia, Canada http://tinyurl.com/4n5pf Submissions
13
by: seemanta dutta | last post by:
Greetings C gurus, I have used preprocessor directives since a very long time. But whenever I see some professional piece of C code, the linux kernel for example, I get literally confused by the...
6
by: francesco | last post by:
I'm programming an embedded system, on a Fujitsu microcontroller. Stated that I'm not sure about constants optimization, I'm trying to declare constants in two ways, one for debug version and one...
13
by: Chris Croughton | last post by:
Is the following code standard-compliant, and if so what should it do? And where in the standard defines the behaviour? #include <stdio.h> #define DEF defined XXX int main(void) { int...
2
by: Christopher Ireland | last post by:
Hello, I'm looking for a C# Preprocessor (shareware with source, if possible) which has the functionality of preprocessors which already exist in other languages, e.g. ...
31
by: Sam of California | last post by:
Is it accurate to say that "the preprocessor is just a pass in the parsing of the source file"? I responded to that comment by saying that the preprocessor is not just a pass. It processes...
9
by: wenmang | last post by:
Hi, all: I have a question regarding to how to solve following problem: I have header called myHeader.h which #define MAX_LEN 100 (legacy code). Now, I like to put most commonly used in...
13
by: josh | last post by:
Hi, I've read that in the future the C++ will not more support the preprocessor and now some preprocessor functionality have already been implemented in the language itself. What are that? ...
36
by: anon.asdf | last post by:
Hello! Can the proprocessor make conditional decisions. Here's an example of the functionality (not standard C!) #define PUT_BYTE(const_index, val) \ #preprocessor_if (const_index ==...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.