I generated a hash function with gperf couple of days ago. What I saw for the hash function was alien to me. It was something like this (I don't remember the exact syntax) :
unsigned int
hash(str, size)
   register char* str;
   register unsigned int size;
{
   //Definition
}
Now, when I tried to compile with a C++ compiler (g++) it threw errors at me for not having str and size declared. But this compiled on the C compiler (gcc). So, questions:
- I thought C++ was a superset of C. If its so, this should compile with a C++ compiler as well right?
- How does the C compiler understand the definition? strandsizeare undeclared when they first appear.
- What is the purpose of declaring strandsizeafter function signature but before function body rather than following the normal approach of doing it in either of the two places?
- How do I get this function to compile on g++ so I can use it in my C++ code? Or should I try generating C++ code from gperf? Is that possible?
 
     
     
     
    