title: Objective-C macro to return a string with the function and the line number while accepting a string with a variable number of arguments?
body: <p>I've found a bunch of macro variations on how to use NSLog as a basis and adding <strong>PRETTY_FUNC</strong> and <strong>LINE</strong> but all the variations of those macros simply output the result to the console.</p>
  
  <p>I'd like to have a macro that can take a format with a variable number of arguments, add the name of the method and line number where it was called and then return an NSString but so far, the compiler always complains where I call it. My latest version is as follow:</p>
  
  <pre><code>#define FileLog(format, ...) {\
  return [NSString stringWithFormat:@"\n  %s [Line %d] \n       %@",
  __PRETTY_FUNCTION__,
  __LINE__,
  [NSString stringWithFormat:(format), ##__VA_ARGS__]];\
  }
  </code></pre>
  
  <p>Each time I call it from my code, the compiler generates one of those errors:</p>
  
  <pre><code>error: expected expression before '{' token
  </code></pre>
  
  <p>I don't want to write a log class or use a framework for that. There must be a way to do that with a macro? Anyone?</p>
  
  <p>Thanks in advance!</p>