![]() |
|
#1
|
|||
|
|||
preprocessor question??I was looking at a piece of code and trying to figure out how the preprocessor would expand it. I really can't seem to figure it out correctly.
Could someone help me out? I just need a little explanation. I know it's not formatted very well, but I wanted to give exactly what I'm seeing. My guess is that it will just be expanded to just int N, but I'm not sure. Thanks a bunch. CPP / C++ / C Code:
|
|||
|
#2
|
|||
|
|||
Re: preprocessor question??Quote:
...you don't need to ask these kinds of questions. Just drop it into a piece of code and build it (or try to), you'll see what happens. CPP / C++ / C Code:
Here we see that N is being defined, otherwise we'd get an error telling us that (in main) that N is an undefined symbol. And, X is a double, because it uses 8 bytes of storage whereas float is a 4-byte type. Also, you can see exactly what your preprocessor does by taking a look at your tool chain reference to see how to run just the preprocessor and then stop and look at its output. If you want to test macros for proper/expected expansion, you can comment-out any header files that you include, run the preprocessor and look at its output. What book are you using and what tool chain? :davis: |
|
#3
|
|||
|
|||
Re: preprocessor question??My book is "C by dissection" by Al Kelley and Ira Pohl. I'm sorry, but I'm not sure what the tool chain is.
|
|
#4
|
|||
|
|||
Re: preprocessor question??Quote:
What compiler/software are you using? ...also, when mentioning books, you may want to include the copyright date and/or any relevant revision/edition information. If you're using the 4th edition, the copyright date is 2000. The reason for this is so that we know whether or not you're using an outdated (pre-standards) book. If you were, we'd want to point you toward something more recent. :davis: |
|
#5
|
|||
|
|||
Re: preprocessor question??The book is a 4th edition, and my software is VisualStudio.NET.
I just wasn't familiar with the tool chain terminology. |
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The