compilation error

Ron Alexander rcalex at home.com
Tue Oct 10 19:40:54 GMT 2000


Herb,

I changed the SMB_ASSERT back to the original and re-compiled. The errors I
get are like the following:

lib/util.c

Source code
973 SMB_ASSERT(len < 80);

Generated code
 ((len < 80)?(void)0: ((void)( (DEBUGLEVEL >= (0)) && (dbghdr( 0,
("util.c"), (""), (973) ))
   && (dbgtext ("PANIC: assert failed at %s(%d)\n", "util.c", 973)) ),
smb_panic("assert failed")));

If instead of ((void)( (DEBUGLEVEL >= (0)) we had
               (void)( (DEBUGLEVEL >= (0)) then my error goes away.

This means that it should be:
#define SMB_ASSERT(b) ((b)?(void)0: \
        DEBUG(0,("PANIC: assert failed at %s(%d)\n", \
     __FILE__, __LINE__)), smb_panic("assert failed"))

instead of
#define SMB_ASSERT(b) ((b)?(void)0: \
        (DEBUG(0,("PANIC: assert failed at %s(%d)\n", \
     __FILE__, __LINE__)), smb_panic("assert failed")))

I am going to make that change and re-compile everything to see if anything
else breaks.

Ron

-----Original Message-----
From: herb at chomps.engr.sgi.com [mailto:herb at chomps.engr.sgi.com]
Sent: October 10, 2000 12:50 PM
To: Ron Alexander
Cc: Gerald Carter; David Collier-Brown; samba-technical at samba.org
Subject: Re: compilation error


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