I have no idea what that does, and recommend to avoid Strings on Arduino, as they often cause program malfunctions and crashes, due to poor memory management.
The pre-processor knows nothing about c/c++ variables. It works only with strng tokens. This is what your code reduces to, after the pre-processor runs:
String id = "1584";
#define THINGNAME_1 id << Note this is unchanged, because the pp does not recognize id as a variable
//#define TOPICNAME_1 "$aws/things/" THINGNAME_1 "/shadow/update"
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println(id); << Note that THINGNAME_1 is replaced by id
//Serial.println(TOPICNAME_1);
delay(1000);
}
This makes
TOPICNAME_1 = "$aws/things/" id "/shadow/update"
with an illegal mix of string literals and letters. No string concatenation can be made with this construct.
If you want to use the actual content of the variable id then you have to concatenate the strings in code. Otherwise you can write
#define THINGNAME_1 id is changing. id value is dynamically loaded by String id.
that's the whole issue.
first #define is pulling a value from a variable but second #define is not pulling the value from dynamically loaded first #define which is linked with a variable.
If i do static load the first #define, the same second #define pulls a value from that first #define.