Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcd4ba4c

Browse files
authored
Fix pgm_read_ptr in AVR pgmspace.h
Originally, `pgm_read_ptr` used to cast its argument to `const void *`, i.e. a pointer to read-only data. This is incorrect, because the argument is a pointer to a pointer in "flash memory". You cannot cast it to`const void *` and then dereference it, because `void` is not an object type.Also, the pointer itself is read-only, but the data could in theory be mutable. The correct type should be `void *const *`, i.e. a pointer to a read-only pointer to any data.
1 parent45e4e5a commitcd4ba4c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎api/deprecated-avr-comp/avr/pgmspace.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ typedef const void* uint_farptr_t;
103103
#definepgm_read_word(addr) (*(const unsigned short *)(addr))
104104
#definepgm_read_dword(addr) (*(const unsigned long *)(addr))
105105
#definepgm_read_float(addr) (*(const float *)(addr))
106-
#definepgm_read_ptr(addr) (*(constvoid *)(addr))
106+
#definepgm_read_ptr(addr) (*(void *const *)(addr))
107107

108108
#definepgm_read_byte_near(addr) pgm_read_byte(addr)
109109
#definepgm_read_word_near(addr) pgm_read_word(addr)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp