This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: typedef


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]