| |

VerySource

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

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

[Copy link]

1

Threads

1

Posts

2

Credits

Newbie

Rank: 1

Credits
2

 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

28

Posts

16

Credits

Newbie

Rank: 1

Credits
16

 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

66

Posts

43

Credits

Newbie

Rank: 1

Credits
43

 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

24

Posts

20

Credits

Newbie

Rank: 1

Credits
20

 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

21

Posts

15

Credits

Newbie

Rank: 1

Credits
15

 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

21

Posts

15

Credits

Newbie

Rank: 1

Credits
15

 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

Credits

Newbie

Rank: 1

Credits
8

 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

3

Posts

3

Credits

Newbie

Rank: 1

Credits
3

 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

6

Posts

6

Credits

Newbie

Rank: 1

Credits
6

 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-2020|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list