473,394 Members | 1,734 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,394 software developers and data experts.

Explanation on preprocessor directive

60
Can someone explain for me what this guy is doing here. N.B homer_uint64 is a defined data type

#define CLUSTERS_DATAID ((homer_uint64)'CLUS' << 32 | (homer_uint64)'TERS')
Nov 27 '08 #1
2 1458
Savage
1,764 Expert 1GB
[quote] @seforo
This macro would only produce compiler errors when used.
Are you sure that he didn't use quotes to wrap CLUS and TERS instead of apostrophes?

In the rest of this post I will assume he had used quotes.So lets break down this macro.

First part of macro:

(homer_uint64)"CLUS"<<32 does the following:
1.It converts a const string "CLUS" to homer_uint64
2.It shifts its bits for 32 places to the left.

C=0x43
L=0x4C
U=0x55
S=0x53

Before shifting:
0x000000434C5553.

After shifting:
0x434C555300000000


Second part of macro ( (homer_uint64)"TERS") also converts const string to homer_uint64 but it doesn't shift it for 32 places.

So second part is:

T=0x54
E=0x45
R=0x52
S=0x53

0x0000000054455253

And finally bitwise operator OR(|) merges these two and creates:

0x434C555300000000 |
0x0000000054455253
//----------------------------------
0x434C55354455253

[\CODE]

which the author of this macro uses as symbolic constant for cluster data.
Nov 27 '08 #2
seforo
60
He used apostrophes, I just did copy and paste. Thanks for the explanation, it highlighted me a lot.
Nov 27 '08 #3

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

Similar topics

5
by: Boris Kuznetsov | last post by:
This occurs in an empty project when I add the following string: #using <mscorlib.dll> Can anyone tell me why would #using ... not be working???? MSDN says nothing about this error. Please...
16
by: Trying_Harder | last post by:
Is it possible to redefine a macro with global scope after undefining it in a function? If yes, could someone explain how? /If/ my question above isn't very clear you can refer to the...
2
by: Gustavo L. Fabro | last post by:
Greetings. Is there a way to run the preprocessor twice? Rephrasing that, is there a way to: #define SOMETHING #pragma OTHERTHING and have the preprocessor in somecode.cpp evaluate: ...
6
by: olivier.grant | last post by:
Hi All, I'm trying to define a macro that will allow me to write the following code : #include MY_MACRO( NAME, SPACE ) and end up with the following preprocessed code : #include NAME.hpp
5
by: _dwin | last post by:
Hi, Does anyone know how to implement your own preprocessor directive? For instance, I would like to have a directive which goes like: #<directive_name<parameters, ...> ie. #compress...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.