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 escreveu: > Using macros to make some code more readable and maintainable I always se= em > to hit snags. > > Struggling to define the question, I have used examples below to try and > 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 > --=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 .