This is the mail archive of the
mailing list for the GCC project.
Re: warning for typedef'ed type
- To: owinebar at free-expression dot org
- Subject: Re: warning for typedef'ed type
- From: Marc Espie <espie at quatramaran dot ens dot fr>
- Date: Mon, 8 Nov 1999 00:23:50 +0100
- Cc: egcs at egcs dot cygnus dot com
- Organization: Ecole Normale Superieure de Paris
In article <Pine.LNX.email@example.com> you write:
> I can't seem to find a way to force a warning if a function requires an
>argument of a typedef'ed type and is given an argument of the original
>type. For example:
>typedef int scm;
>int f(scm a);
This kind of stuff is very hard to warn about, as C is really not the
right language to achieve this level of control.
You might wish to look into C++. You can define an scm class that will
act as an int (conversion operator), but with no implicit constructor
As another venue, I spent quite some time playing with an advanced
and versatile lint called lclint
It can enforce these kinds of restrictions (typedef to enforce `abstract
types') and lots of other restrictions.
My personal experience was that, though useful, that program demands a huge
investment in time to add enough annotations to a program to make it clean
(let alone the modifications needed to unsafe constructs, and its inability
to cope with some Unix constructs like fork() properly), but your mileage
[Take answers to private email, as this has little relevance to gcc itself].