In article 
<[EMAIL PROTECTED]> of Wed, 
21 Aug 2002 10:19:27 in , David Evans <[EMAIL PROTECTED]> writes
>
>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.
>>
>

I suggest you look at "Strong Type Checking" introduced to the 
www.gimpel.com PC/Flexelint range in 1991.

I recently posted news:[EMAIL PROTECTED]
It shows errors given assignment type mismatches.

The following shows the controls and the types; The controls could be in 
an initialisation file or on a command line.

/*lint -strong(AXJ) -fhd Be fussy about typedef mismatches */

typedef signed long fruit;
typedef fruit orange;
typedef fruit banana;

Of course, those products cost money.
I am a BETA tester and no longer pay for my copies.
-- 
Walter Briscoe

Reply via email to