| |

VerySource

 Forgot password?
 Register
Search
View: 1052|Reply: 8

Help me see. It seems that I have never seen such a definition

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-7 07:00:01
| Show all posts |Read mode
#define XBYTE ((unsigned char volatile xdata *) 0)

What does this definition mean:
Reply

Use magic Report

0

Threads

41

Posts

28.00

Credits

Newbie

Rank: 1

Credits
28.00

 China

Post time: 2020-5-24 13:30:01
| Show all posts
Unsigned char volatile xdata type pointer, the pointer value is 0;
Reply

Use magic Report

0

Threads

73

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 Invalid IP Address

Post time: 2020-5-24 18:00:01
| Show all posts
It is to define a macro, which is equivalent to a null pointer, but the pointer is converted to point to unsigned char volatile xdata type.
Volatile is very similar to const, both are restrictors, and the meaning is just the opposite. One is constant and the other is variable (it may change in the program if it seems to be unchanged. It is mostly used to modify multi-threaded shared variables to prevent the compiler Misunderstood that it does not change and make some optimization)
Reply

Use magic Report

0

Threads

37

Posts

28.00

Credits

Newbie

Rank: 1

Credits
28.00

 China

Post time: 2020-5-25 13:30:01
| Show all posts
((unsigned char volatile xdata *) 0) is a null pointer of type unsigned char
volatile is to remind the compiler not to optimize access to this variable, because it may be modified by another thread.
Reply

Use magic Report

1

Threads

39

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-5-28 20:00:01
| Show all posts
Define a pointer. The name is xdata;
The type is: unsigned char volatile *
The initial value is: 0
Among them, volatile means that the compiler does not optimize the value.
Reply

Use magic Report

1

Threads

39

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-6-20 12:00:02
| Show all posts
Oh.
What is xdata?
Haha
Reply

Use magic Report

2

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-6-26 14:15:01
| Show all posts
I haven't seen this kind of define. It seems that after the 0 is added later, this XBYTE is not easy to use.
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-6-28 10:30:01
| Show all posts
Define a pointer. The name is xdata;
The type is: unsigned char volatile *
The initial value is: 0
=============================================
I have never seen such an initial value, and the test failed



Among them, volatile means that the compiler does not optimize the value.
=============================================
Note that when the compiler does not optimize, volatile may not work, but when you start optimizing code (when the compiler starts looking for redundant reads), you can prevent major errors.
(From "C++ Programming Ideas Volume One 2nd Edition" P73)

LZ may wish to send out the code that refers to this macro to see
Reply

Use magic Report

0

Threads

8

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-6-29 16:00:02
| Show all posts
xdata refers to a pointer to the xdata area.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list