typedef

Alexandre Oliva aoliva@redhat.com
Mon Mar 12 21:10:00 GMT 2001


On Mar 12, 2001, Martin Strauss <mys@faveve.uni-stuttgart.de> wrote:

> The following program compiles usually without reporting a warning ...
> but it should because of a kind of type missmatch :
> */

> typedef int value_t;
> typedef int counter_t;
> int main(){
>  value_t v=0;
>  counter_t c=0;
>  v=c;  /* makes no sense */

Nope.  In C, typedefs are type *aliases*, not unrelated types.

You might play with int-like classes in C++; that might give you
increased type safety.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me



More information about the Gcc-help mailing list