compilation error

Herb Lewis herb at chomps.engr.sgi.com
Tue Oct 10 16:49:46 GMT 2000


Ron Alexander wrote:
> 
> Actually I started this, and DCB tested it on one of his SUN boxes. We both
> got severe compile errors.
> 
> I am not a language lawyer, but everyone I have shown this to says the same
> thing, "it's invalid C syntax".
> 

I disagree. If you look at what actually gets generated, you are mixing
two different types as the results of the conditional operator.

The 0 by default is type int. The DEBUG macro is defined as type (void).
So you say if x is true make the expression an int but if x is false
make 
the expression a void. The IRIX compiler forces you to declare both
operands as the same type. Maybe you could argue that this is too
restrictive but I wouldn't call it a bug. 

Either of the following would be correct (I simplified the macro to 
make it easier to see what is happening printf is decalred an int)

#define SMB_ASSERT(b) ((b)?(void)0: (void)printf(""))
#define SMB_ASSERT_OK(b) ((b)?0: printf(""))


> I respectfully submit that the IRIX C compiler has a bug if it requires this
> syntax. If that is the case, then the code should be changed to ifdef the
> IRIX case since it is the one that is unique.
> 
> I can find and forward original e-mail between me and DCB and
> samba-technical if needed.
> 
> Ron Alexander

-- 
======================================================================
Herb Lewis                               Silicon Graphics 
Networking Engineer                      1600 Amphitheatre Pkwy MS-510
Strategic Software Organization          Mountain View, CA  94043-1351
herb at sgi.com                             Tel: 650-933-2177
http://www.sgi.com                       Fax: 650-932-2177          
======================================================================




More information about the samba-technical mailing list