Skip to content

fix: use PROGMEM macro#8

Closed
sleepdefic1t wants to merge 2 commits intociband:masterfrom
sleepdefic1t:patch-1
Closed

fix: use PROGMEM macro#8
sleepdefic1t wants to merge 2 commits intociband:masterfrom
sleepdefic1t:patch-1

Conversation

@sleepdefic1t
Copy link

Some platforms now throw the error: 'const void*' is not a pointer-to-object type with PIO in Linux.
It appears they handle PROGMEM differently.
This PR adds a macro resolves "pointer-to-object" errors in those platforms.


PGM Macro:

#if defined(ESP8266) |              \
    defined(ARDUINO_SAMD_MKRZERO) | \
    defined(ARDUINO_SAMD_ZERO) |    \
    defined(ARDUINO_SAM_DUE) |      \
    defined(ARDUINO_ARCH_ARC32) |   \
    defined(__TC27XX__) |           \
    (defined(TEENSYDUINO) && (TEENSYDUINO < 139))
#undef pgm_read_ptr
#define pgm_read_ptr(addr) (*(const void **)(addr))
#endif

src: SlashDevin/NeoGPS#112


Example Build Error:

In file included from /home/circleci/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:163:0,
from /home/circleci/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/Arduino.h:33,
from .piolibdeps/bip39_ID5886/src/util.h:13,
from .piolibdeps/bip39_ID5886/src/dictionary/english_str.h:4,
from .piolibdeps/bip39_ID5886/src/dictionary/english.h:4,
from .piolibdeps/bip39_ID5886/src/bip39.cpp:2:
.piolibdeps/bip39_ID5886/src/bip39.cpp: In function 'int BIP39::{anonymous}::get_word_index(const char* const*, const string&)':
.piolibdeps/bip39_ID5886/src/bip39.cpp:52:28: error: 'const void*' is not a pointer-to-object type
strcpy_P(w, (char*)pgm_read_ptr_far(&(lexicon[i]))); // NOLINT
^
/home/circleci/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include/sys/string.h:32:57: note: in definition of macro 'strcpy_P'
#define strcpy_P(dest, src)          strncpy_P((dest), (src), SIZE_IRRELEVANT)
^
.piolibdeps/bip39_ID5886/src/bip39.cpp: In function 'BIP39::word_list BIP39::create_mnemonic(std::vector<unsigned char>&, BIP39::language)':
.piolibdeps/bip39_ID5886/src/bip39.cpp:106:31: error: 'const void*' is not a pointer-to-object type
strcpy_P(word, (char*)pgm_read_ptr_far(&(lexicon[position]))); // NOLINT
^
/home/circleci/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include/sys/string.h:32:57: note: in definition of macro 'strcpy_P'
#define strcpy_P(dest, src)          strncpy_P((dest), (src), SIZE_IRRELEVANT)
^
*** [.pioenvs/esp8266/src/test/.piolibdeps/bip39_ID5886/src/bip39.cpp.o] Error 1

Some platforms now throw the error: `'const void*' is not a pointer-to-object type` with PIO in Linux.

e.g.
```
In file included from /home/circleci/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:163:0,
from /home/circleci/.platformio/packages/framework-arduinoespressif8266/cores/esp8266/Arduino.h:33,
from .piolibdeps/bip39_ID5886/src/util.h:13,
from .piolibdeps/bip39_ID5886/src/dictionary/english_str.h:4,
from .piolibdeps/bip39_ID5886/src/dictionary/english.h:4,
from .piolibdeps/bip39_ID5886/src/bip39.cpp:2:
.piolibdeps/bip39_ID5886/src/bip39.cpp: In function 'int BIP39::{anonymous}::get_word_index(const char* const*, const string&)':
.piolibdeps/bip39_ID5886/src/bip39.cpp:52:28: error: 'const void*' is not a pointer-to-object type
strcpy_P(w, (char*)pgm_read_ptr_far(&(lexicon[i]))); // NOLINT
^
/home/circleci/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include/sys/string.h:32:57: note: in definition of macro 'strcpy_P'
#define strcpy_P(dest, src)          strncpy_P((dest), (src), SIZE_IRRELEVANT)
^
.piolibdeps/bip39_ID5886/src/bip39.cpp: In function 'BIP39::word_list BIP39::create_mnemonic(std::vector<unsigned char>&, BIP39::language)':
.piolibdeps/bip39_ID5886/src/bip39.cpp:106:31: error: 'const void*' is not a pointer-to-object type
strcpy_P(word, (char*)pgm_read_ptr_far(&(lexicon[position]))); // NOLINT
^
/home/circleci/.platformio/packages/framework-arduinoespressif8266/tools/sdk/libc/xtensa-lx106-elf/include/sys/string.h:32:57: note: in definition of macro 'strcpy_P'
#define strcpy_P(dest, src)          strncpy_P((dest), (src), SIZE_IRRELEVANT)
^
*** [.pioenvs/esp8266/src/test/.piolibdeps/bip39_ID5886/src/bip39.cpp.o] Error 1
```

This found fix seems to resolve these build issues.
@codecov
Copy link

codecov bot commented Apr 16, 2019

Codecov Report

Merging #8 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master       #8   +/-   ##
=======================================
  Coverage   94.22%   94.22%           
=======================================
  Files           6        6           
  Lines         225      225           
=======================================
  Hits          212      212           
  Misses         13       13
Impacted Files Coverage Δ
src/bip39.cpp 94.38% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ab4b4a...a55f13d. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Apr 16, 2019

Codecov Report

Merging #8 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master       #8   +/-   ##
=======================================
  Coverage   94.22%   94.22%           
=======================================
  Files           6        6           
  Lines         225      225           
=======================================
  Hits          212      212           
  Misses         13       13
Impacted Files Coverage Δ
src/bip39.cpp 94.38% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ab4b4a...a55f13d. Read the comment docs.

@codecov-io
Copy link

Codecov Report

Merging #8 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master       #8   +/-   ##
=======================================
  Coverage   94.22%   94.22%           
=======================================
  Files           6        6           
  Lines         225      225           
=======================================
  Hits          212      212           
  Misses         13       13
Impacted Files Coverage Δ
src/bip39.cpp 94.38% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ab4b4a...3233e45. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Apr 19, 2019

Codecov Report

Merging #8 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master       #8   +/-   ##
=======================================
  Coverage   94.22%   94.22%           
=======================================
  Files           6        6           
  Lines         225      225           
=======================================
  Hits          212      212           
  Misses         13       13
Impacted Files Coverage Δ
src/util.h 100% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ab4b4a...3233e45. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants