title: Is comparing pointers of strings valid in this case?
body: <p>In my C application, I have a logging method similar to this:</p>
  
  <pre><code>void logError(const char* module, const char* message, ... );
  </code></pre>
  
  <p>When this method is called, callers often do something like the following:</p>
  
  <pre><code>logError("foo", "bar");
  
  // or even
  
  #define FOOMODULE "foo"
  logError(FOOMODULE, "bar");
  </code></pre>
  
  <p>No matter how the <code>char*</code> module gets passed in, the <code>char*</code> is static memory stored in the application binary.</p>
  
  <p>My question is, does the compiler/linker collapse all instances of a statically declared string into a single declaration?  As such, is it valid to assume that comparing the pointers (<code>"foo" == FOOMODULE</code>) of my statically declared strings will always work as expected (assuming, of course, that the strings <em>are</em> equivalent as in my example above and that both <em>are indeed</em> statically allocated in the app's binary)?</p>
  
  <p>I'm working on a way to filter on log messages as they come in.  For example, perhaps I only want to see log messages from a single 'module'.  It would be great to compare the pointers and not each byte in the string when deciding if I want to actually print a given log message.</p>
  
  <p>Thanks!</p>