But is required to be an unsigned integral type. (According to
the current C++ standard, it must be a standard unsigned
integral type; i.e. one of "unsigned char", "unsigned short",
"unsigned int" or "unsigned long". C99 and I believe the next
version of the C++ standard will allow an extended integral
types as well, e.g. uint64_t, where even long is only 32 bits.)
Yes but I have been confused by this:
By snooping where you have no business snooping
.
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
#endif
#if !(defined (__GNUG__) && defined (size_t))
typedef __SIZE_TYPE__ size_t;
now why is **defined** __SIZE_TYPE__ and not simple
typedef long unsigned int __SIZE_TYPE__
Because that's the way the authors of this particular library
wanted to do it. (I suspect that it has something to do with
the way they handle system dependencies.) At any rate, anything
with a double underscore is of no concern to you, unless the
compiler documentation explicitly says otherwise. (Some---I
think even many---compilers use macros with double underscores
to turn features on or off. That's obviously not the case
here.)
and when is written >> defined (size_t)) where is size_t before type-
defined?
Again, it's something internal to the implementation.
"defined( size_t )" will only evaluate to true if size_t is
already defined as a macro. Which isn't allowed: the
implementation isn't allowed to define size_t as a macro, and if
you define it as one, it is undefined behavior. Apparently,
your library "defines" the undefined behavior, as an extension.
I can't imagine a case where it would be useful,
however---perhaps when compiling some special kernel code?
Don't do it, unless you really, really know what you are doing.
and also how is used typedef???
Typedef defines a symbol which is the name of the type. You
write the declaration exactly like any other declaration, but
the name being defined is not a variable, but the name of a
type, which can be used as the name of a type whenever it is in
scope. E.g.:
int array[ 10 ] ; // defines an array of 10 ints,
// a variable.
typedef int Array10[ 10 ] ; // defines a symbol Array10,
// which can be used as the
// name of a type.
Array10 array2 ; // defines an array of 10 ints,
// a variable.
when compiler meets >> typedef __SIZE_TYPE__ size_t;
it should convert __SIZE_TYPE__ in long unsigned int accordingly with
previous #define __SIZE_TYPE__ long unsigned int but typedef don't
want
like its first operand the type synonymous and like second operand the
real type??
I'm having difficulty parsing that last phrase. After macro
expansion, yes, you have:
typedef long unsigned int size_t ;
If size_t is already defined in the scope, it is an error.
Otherwise, it defines a new symbol, size_t, as a synonym for the
type long unsigned ing.