Pgm_read_word() pointer error on 32bit system


even if it seems a bit senseless, i have compiled uLisp Zero for an M5Stack (ESP32). This resulted in the following “warning”:

"cast to pointer from integer of different size [-Wint-to-pointer-cast]"

and the program flow crashes. I was able to fix the problem by calling


instead of


in the following functions:

fn_ptr_type lookupfn (symbol_t name) {
  return (fn_ptr_type)pgm_read_ptr(&lookup_table[name].fptr);

char *lookupbuiltin (symbol_t name) {
  strcpy_P(Buffer, (PGM_P)(pgm_read_ptr(&lookup_table[name].string)));
  return Buffer;

The reason is that the function pgm_read_word() returns a 16bits pointer but a 32bit one is necessary because otherwise the call will end up somewhere where it should not end up… On a 32bit System…

I do not know exactly what I will use uLisp Zero on a ESP32 for, but it was exciting to realize it and it was very instructive.

Best regards


Thanks for reporting that. I had a look at the equivalent functions in the full ESP version of uLisp, and I think they’ve been fixed; it might be better to use those versions.