Approved: Fortect
Over the past few weeks, some readers have encountered an error code with a void pointer, which is used for arithmetic errors. This problem occurs due to several factors. Now we will deal with them.
Requested
Visited 28000 times
I have experience writing and reading registers from crammap like this:
// READreturn * ((volatile uint32_t *) (roadmap + offset));// WRITE* ((volatile uint32_t *) (location + offset)) = value;
Warning: hint like "void *" used in math [-Wpointer-arith]
How do I change the code that suppresses warnings? I am using C ++ and Linux.
requested November 5, 2014 at 11:04 am
1321
Not The Answer You Are Looking For? Scroll Through Other Questions Tagged With C ++ Pointers, Null Pointer, Pointer Arithmetic, Or Ask Your Own Question.
Approved: Fortect
Fortect is the world's most popular and effective PC repair tool. It is trusted by millions of people to keep their systems running fast, smooth, and error-free. With its simple user interface and powerful scanning engine, Fortect quickly finds and fixes a broad range of Windows problems - from system instability and security issues to memory management and performance bottlenecks.
Since void *
is a valid pointer to an unknown type, you cannot perform pointer arithmetic because the compiler does not explicitly know the size of the object that the reference points to.
The best way to do this is to help you convert map
to a type, which was then one byte wide, and do some arithmetic. For many of them you can use uint8_t
:
// READreturn * ((volatile uint32_t *) (((uint8_t *) map) + cancel));// WRITE* ((volatile uint32_t *) (((uint8_t *) map) + decrease)) = value;
654
Answered Nov 5, 2014 11:34 am
56.6k
The void type is an incomplete type. Its size is unknown. So show that the math with the clues to the vacuum doesn’t really make sense. You must cast a pointer that is returned to type void to a pointer of a different type. An example of a pointer can be written char.Also note that clients are not allowed to assign an object declared using the volatile qualifier.
answered Nov 14, 14 at 11:14
231,000
If the way to useI arithmetic for null recommendations is really what you need, since computation is made possible by GCC (see Arithmetic for null pointers and function pointers), you can use -Wno-pointer-arith <. use / code> to suppress the warning.
answered Jan 21 '15 at 11:20
164
Speed up your computer's performance now with this simple download.