Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can anyone explain me this code

Tags:

c++

#ifndef EIGHT_BIT
#define THIRTYTWO_BIT // default 32 bit
#endif

#ifdef THIRTYTWO_BIT
#define WORD unsigned long
#define WORDLENGTH 4

#if defined(WIN32) && !defined(__GNUC__)
#define WORD64  unsigned __int64
#else
#define WORD64  unsigned long long
#endif

// THIRTYTWO_BIT
#endif


#ifdef EIGHT_BIT

#define WORD unsigned short
#define WORDLENGTH 4

// EIGHT_BIT
#endif
like image 772
Pramod Avatar asked Aug 28 '26 05:08

Pramod


2 Answers

It's just a definition of constants (aka defines) depending on the #define EIGHT_BIT.

If EIGHT_BIT is defined, WORD means unsigned short and WORDLENGTH is 4. Otherwise, WORD is unsigned long and WORDLENGTH is also 4. Additionally, WORD64 will be defined as unsigned long long unless you are on a WIN32 system and not using GCC.

like image 97
Tobias Langner Avatar answered Aug 30 '26 17:08

Tobias Langner


All the "code" does it setup pre-processor symbols for any "live" code that you do have. If a symbol called EIGHT_BIT is defined before this code is pre-processed, it sets up WORD and WORDLENGTH accordingly (though WORDLENGTH's value is suspect), and it will set up the values differently if EIGHT_BIT is not already defined.

like image 38
Jim Buck Avatar answered Aug 30 '26 17:08

Jim Buck



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!