You could fake this by making them enum types:

# ifdef S_SPLINT_S
typedef enum { S_JUNK1 } seconds;
typedef enum { S_JUNK2 } minutes;
# else
typedef int seconds;
typedef int minutes;
# endif

If you used the -enumint flag, then you'll get the warnings you want for
this.

--- Dave

On Wed, 21 Aug 2002, Simon Hosie wrote:

> Was searching the archives and found the post about using /*@abstract@*/ in a 
>typedef.  That's almost what I'm after, but it's much too obstructive for me.  What 
>I'd like is something along these lines:
>
>       typedef /*@abstract@*/ int seconds;
>       typedef /*@abstract@*/ int minutes;
>
>       void test(void)
>       {
>               seconds tod_sec = (seconds)5;           // legal
>               minutes tod_min = (minutes)7;           // legal
>
>               tod_min++;                                      // legal
>               tod_sec = tod_min;                      // illegal
>               tod_min = 10;                           // illegal
>
>               if (tod_min > tod_sec)                  // illegal
>                       ;
>       }
>
> 'tod_min = 10' may be clear in context, but it could easily be obfuscated by macros 
>or less obvious variable names... so I'd be happy to see it trapped.
>

Reply via email to