c++ - How does this function definition work? -


i generated hash function gperf couple of days ago. saw hash function alien me. (i don't remember exact syntax) :

unsigned int hash(str, size)    register char* str;    register unsigned int size; {    //definition } 

now, when tried compile c++ compiler (g++) threw errors @ me not having str , size declared. compiled on c compiler (gcc). so, questions:

  1. i thought c++ superset of c. if so, should compile c++ compiler right?
  2. how c compiler understand definition? str , size undeclared when first appear.
  3. what purpose of declaring str , size after function signature before function body rather following normal approach of doing in either of 2 places?
  4. how function compile on g++ can use in c++ code? or should try generating c++ code gperf? possible?

1.  c++ not superset, although not standard c either.

2/3. k&r function declaration. see what major differences between ansi c , k&r c? .

4. gperf in fact have option, -l, specify language. can use -l c++ use c++.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -