Index: src/util.cpp
===================================================================
--- src/util.cpp	(revision 775)
+++ src/util.cpp	(working copy)
@@ -64,6 +64,8 @@
 #include <unistd.h>
 #endif
 
+#define ANONNS_START_KEY "anonymous_namespace{"
+#define ANONNS_END_KEY "}"
 
 //------------------------------------------------------------------------
 
@@ -4138,6 +4140,30 @@
   return TRUE; 
 }
 
+static QCString substituteWithAnon(const QCString &name, const char* from,
+    const char* to)
+{
+  QCString ret;
+  int keyStart;
+  int keyEnd = 0;
+
+  while ((keyStart = name.find(ANONNS_START_KEY, keyEnd)) != -1)
+  {
+    if (keyEnd > keyStart) ret += substitute(name.mid(keyEnd, keyStart), from, to);
+    keyEnd = name.find(ANONNS_END_KEY, keyStart);
+    if (keyEnd == -1)
+    {
+      ret += name.mid(keyStart);
+      return ret;
+    }
+    else
+      ret += name.mid(keyStart, keyEnd - keyStart + 1);
+    keyEnd++;
+  }
+  ret += substitute(name.mid(keyEnd, keyStart), from, to);
+  return ret;
+}
+
 /*! Returns an object to reference to given its name and context 
  *  @post return value TRUE implies *resContext!=0 or *resMember!=0
  */
@@ -4154,8 +4180,12 @@
   QCString tsName = name;
   //bool memberScopeFirst = tsName.find('#')!=-1;
   QCString fullName = substitute(tsName,"#","::");
-  fullName = removeRedundantWhiteSpace(substitute(fullName,".","::"));
 
+  int anonPos = fullName.find(ANONNS_START_KEY);
+  // anonymous namespace contains dot in name. Simple substitute can't be used
+  if (anonPos == -1) fullName = removeRedundantWhiteSpace(substitute(fullName,".","::"));
+  else fullName = substituteWithAnon(removeRedundantWhiteSpace(fullName),".","::");
+
   int bracePos=fullName.findRev('('); // reverse is needed for operator()(...)
   int endNamePos=bracePos!=-1 ? bracePos : fullName.length();
   int scopePos=fullName.findRev("::",endNamePos);
@@ -7163,3 +7193,21 @@
   }
 }
 
+int compareNamesWithAnon(const char *item1,const char *item2)
+{
+  if (strstr(item1, ANONNS_START_KEY) == item1)
+  {
+     if (strstr(item2, ANONNS_START_KEY) == item2)
+        return stricmp(item1, item2);
+     else
+        return 1;
+
+  }
+  else
+  {
+     if (strstr(item2, ANONNS_START_KEY) == item2)
+        return -1;
+     else
+        return stricmp(item1, item2);
+  }
+}
Index: src/namespacedef.h
===================================================================
--- src/namespacedef.h	(revision 775)
+++ src/namespacedef.h	(working copy)
@@ -154,7 +154,7 @@
    ~NamespaceSDict() {}
     int compareItems(GCI item1,GCI item2)
     {
-      return stricmp(((NamespaceDef *)item1)->name(),
+      return compareNamesWithAnon(((NamespaceDef *)item1)->name(),
                     ((NamespaceDef *)item2)->name()
                    );
     }
Index: src/classlist.cpp
===================================================================
--- src/classlist.cpp	(revision 775)
+++ src/classlist.cpp	(working copy)
@@ -39,7 +39,7 @@
   //printf("compItems: %d %s<->%s\n",b,c1->name().data(),c2->name().data());
   if (b) 
   { 
-     return stricmp(c1->name(),
+     return compareNamesWithAnon(c1->name(),
                     c2->name());
   }
   else
Index: src/doctokenizer.l
===================================================================
--- src/doctokenizer.l	(revision 775)
+++ src/doctokenizer.l	(working copy)
@@ -306,6 +306,7 @@
 HFILEMASK ("."{FILESCHAR}*{FILEECHAR}+)*
 FILEMASK  ({FILESCHAR}*{FILEECHAR}+("."{FILESCHAR}*{FILEECHAR}+)*)|{HFILEMASK}
 LINKMASK  [^ \t\n\r\\@<&${}]+("("[^\n)]*")")?({BLANK}*("const"|"volatile"){BLANK}+)? 
+ANONMASK  "anonymous_namespace{"{FILEMASK}"}"("::"|"#")
 VERBATIM  "verbatim"{BLANK}*
 SPCMD1    {CMD}([a-z_A-Z][a-z_A-Z0-9]*|{VERBATIM})
 SPCMD2    {CMD}[\\@<>&$#%~"]
@@ -853,7 +854,7 @@
                          g_token->name = g_token->name.stripWhiteSpace();
 			 return TK_WORD;
   		       }
-<St_Link>{LINKMASK}|{REFWORD}    {
+<St_Link>{ANONMASK}*{LINKMASK}|{REFWORD}    {
                          g_token->name = yytext;
 			 return TK_WORD;
                        }
Index: src/classdef.h
===================================================================
--- src/classdef.h	(revision 775)
+++ src/classdef.h	(working copy)
@@ -473,7 +473,7 @@
       if (c1==0 || c2==0) 
         return FALSE;
       else
-        return stricmp(c1->name(),c2->name());
+        return compareNamesWithAnon(c1->name(),c2->name());
     }
 };
 
Index: src/util.h
===================================================================
--- src/util.h	(revision 775)
+++ src/util.h	(working copy)
@@ -410,5 +410,7 @@
 bool copyFile(const QCString &src,const QCString &dest);
 QCString extractBlock(const QCString text,const QCString marker);
 
+int compareNamesWithAnon(const char *item1,const char *item2);
+
 #endif
 
