A community for students.
Here's the question you clicked on:
 0 viewing
Curry
 one year ago
What does the following way of defining a variable mean? #define COUNT ((long) (sizeof(long) <<1))
Curry
 one year ago
What does the following way of defining a variable mean? #define COUNT ((long) (sizeof(long) <<1))

This Question is Closed

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0it's a macro that defines COUNT as the size of a long shifted one bit to the left sizeof(long) = 4 0100 moved one bit to the left 1000 or 8

Curry
 one year ago
Best ResponseYou've already chosen the best response.0so how do i write macros?

Curry
 one year ago
Best ResponseYou've already chosen the best response.0like what defines it, how would i write another one if I wanted to? and why not just use a 8 byte variable type.

Curry
 one year ago
Best ResponseYou've already chosen the best response.0And how exactly would I use the macro? esp seince it's called a function.

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0this one is a variable. macros can also be functions though ``` //taken from http://stackoverflow.com/a/3437442/2761134 #define MAX(a,b) ((a) > (b) ? a : b) #define MIN(a,b) ((a) < (b) ? a : b) ```

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0Macros are executed by the preprocessor, and they only ever do text replacement. ``` #define MAX(a,b) ((a) > (b) ? a : b) int f() { return MAX(2, 4); } ``` Putting this through the preprocessor will get you something like: ``` int f() { return ((2) > (4) ? 2 : 4); } ``` Which will then later on be compiled. So obviously your macros should only do really simple things. Other languages don't even have this feature, because some consider it dangerous.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.