That line is actually part of a string that contains javascript that is embedded in html that is sent to the browser client when requested. so the plus signs are actually in the javascript code. server.sendContent(F("var arrpv=3D[];" ... "var pidupdate=3D' " STRING_PREAMBLE " ' +ID+ ' , ' +posVal; console.log('pidupdate:'+pidupdate); " ... ")); I guess it would have been clearer if I said I want to do something like this #define STRING_PREAMBLE "@" strHTML[] =3D "sometext " STRING_PREAMBLE "someothertext" ; As best as I can tell the above expands to strHTML[] =3D "sometext " "@" "someothertext" and effectively produces strHTML[] =3D "sometext @someothertext" and works ok until I try if (payload[0] =3D=3D STRING_PREAMBLE) which expand to if (payload[0] =3D=3D "@") which the compiler does not like. I am using the Arduino IDE to compile code for the ESP8266. As best as i can tell the IDE/compiler accepts both C and C++ justin On Sun, Sep 29, 2019 at 8:35 PM Isaac M. Bavaresco wrote: > Are you using C++? > > Because in > > pidupdate=3D'"STRING_PREAMBLE"'+ID+','+posVal;console.log('pid > update:'+pidupdate) > > The plus signs are not valid in C to concatenate strings, also, if posVal > is a variable then even without the plus signs it would not work. > > In C you could write: > > #define STRING_PREAMBLE @ > #define STRINGIFY_(c) #c > #define STRINGIFY(c) STRINGIFY_(c) > > Then: > > char *pidupdate=3DSTRINGIFY(STRING_PREAMBLE) ID "," posVal; > > I just noticed you are using single quotes for some elements of the > expression. I'm pretty sure you must be using C++. > > C++ is not C. They have important differences. > > Cheers, > Isaac > > > > Em dom, 29 de set de 2019 05:03, Justin Richards < > justin.richards@gmail.com> > escreveu: > > > Using macros to make some code more readable and maintainable I always > seem > > to hit snags. > > > > Struggling to define the question, I have used examples below to try an= d > > illustrate my query. > > > > I wanted to convert this > > > > if (payload[0] =3D=3D '@') > > { > > ... > > } > > > > to > > #define STRING_PREAMBLE '@' > > > > if (payload[0] =3D=3D STRING_PREAMBLE) > > { > > ... > > } > > > > The compiler complains with "expected ')' before '@' > > > > So i tried variations on the theme > > #define STRING_PREAMBLE @ > > #define STRING_PREAMBLE "'@'" > > #define STRING_PREAMBLE "@" > > > > The later two variations compiles but the following comparison fails > > if (payload[0] =3D=3D 'STRING_PREAMBLE') > > > > The macro is used elsewhere in the code as part of a string of embedded > > HTML that embeds javascript and behaves as required > > "var > > > > > pidupdate=3D'"STRING_PREAMBLE"'+ID+','+posVal;console.log('pidupdate:'+pi= dupdate);" > > > > this was previously coded as > > > > "var pidupdate=3D'@'+ID+','+posVal;console.log('pidupdate:'+pidupdate);= " > > > > Any hints or suggestions on how i should phrase my search. > > > > Justin > > -- > > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > > View/change your membership options at > > http://mailman.mit.edu/mailman/listinfo/piclist > > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .