GCC msg "note: in definition of macro 'max'" error message
I can reproduce your message easily enough:

#define max(a,b) ((a)&gt;(b)?(a):(b))

void setup() {
 int b = 66;
 unsigned int c = 42;
 analogWrite (3, max (b, c));
}

void loop() { }


I get these warnings:

/tmp/arduino_modified_sketch_857720/sketch_aug31a.ino: In function 'void setup()':
/tmp/arduino_modified_sketch_857720/sketch_aug31a.ino:1:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define max(a,b) ((a)&gt;(b)?(a):(b))
                         ^
/tmp/arduino_modified_sketch_857720/sketch_aug31a.ino:6:18: note: in expansion of macro 'max'
  analogWrite (3, max (b, c));


The point is that the warning note: in expansion of macro 'max' is just telling you where the macro is defined, so you can make sense of the real warning. The real warning is: warning: comparison between signed and unsigned integer expressions

So, reading them together, you are comparing (in the macro) a signed and unsigned number, and the compiler is warning you about that.


  The message seems like a red herring, given that there is no problem with the max(a,b) macro definition. I suspect it is being flagged only because it was tangentially involved with a statement in error.


That's right. There is no problem in that macro per se. Macros can generate weird error message because they are just text replacements. For example:

max (the quick brown fox, jumps over the lazy dog);


That will generate a slew of errors, including a "note" to where max is defined. There is nothing wrong with max until you try feeding garbage into it.



Templates

That's one of the reasons I prefer to avoid macros if possible. You can do "max" with a template. For example:

#undef max   // throw away the original macro in the Arduino header file

template&lt;typename T&gt; T max (T a, T b)
  {
  if (a &gt; b)
    return a;

  return b;
  }


Now you get slightly more reasonable error messages:

/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino: In function 'void setup()':
sketch_aug31a:14: error: no matching function for call to 'max(int&amp;, unsigned int&amp;)'
   analogWrite (3, max (b, c));
                            ^
/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino:14:28: note: candidate is:
/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino:3:24: note: template&lt;class T&gt; T max(T, T)
 template&lt;typename T&gt; T max (T a, T b)
                        ^
/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino:3:24: note:   template argument deduction/substitution failed:
/tmp/arduino_modified_sketch_711186/sketch_aug31a.ino:14:28: note:   deduced conflicting types for parameter 'T' ('int' and 'unsigned int')
   analogWrite (3, max (b, c));
                            ^
exit status 1
no matching function for call to 'max(int&amp;, unsigned int&amp;)'


Of course, now you've gone from a warning to an error, because the template wants a single type.

Notice the notes? That's just the compiler trying to be helpful.



You could make the template take two types if you are prepared to guess the return type (will it be the first type, or the second type?):

#undef max

template&lt;typename T1, typename T2&gt; T1 max (T1 a, T2 b)
  {
  if (a &gt; b)
    return a;

  return b;
  }


Now you don't get an error or a warning, however the result will be the first type (T1) which may or may not suit you.