Possible to modify a const with internal linkage... externally?

67 Views Asked by At

I am doing a project that uses a library with source code I want to leave unaltered. Inside one of the library's source code files is a global const c-style string array that I want to alter externally from another file in the project:

const u8 STRING_PRODUCT[] PROGMEM = USB_PRODUCT;

By default global constants have internal linkage. Is there anyway to possible change this array without touching the code in this file? Or can I at least somehow get the memory address of this array and then use a pointer to alter it? Thank you!

1

There are 1 best solutions below

0
On

No need to modify the source code. USB_PRODUCT is defined in USBCore.cpp only if it's not already defined, so just define it as whatever you want when compiling the library. (Reference)