[Disksim-users] Compile error - duplicate case value

Michael Stroucken stroucki at ece.cmu.edu
Fri Apr 15 15:35:30 EDT 2011


Adam Crume wrote:
> Sorry, it looks like the in-reply-to got swallowed.  Here's the 
> original message: 
> https://sos.ece.cmu.edu/pipermail/disksim-users/2009-January/000359.html
>
> On Fri, Apr 15, 2011 at 11:45 AM, Adam Crume <adamcrume at gmail.com 
> <mailto:adamcrume at gmail.com>> wrote:
>
>     I ran into the same problem.  The code won't compile, and the
>     problem seems to be this assertion:
>
>     StaticAssert (sizeof(ioreq_event) <= DISKSIM_EVENT_SIZE);
>
>     Any fixes/workarounds?
>
>     Here's my setup:
>     Linux birgitte 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:46
>     UTC 2011 x86_64 GNU/Linux
>     gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
>
>

Here's what I would say:-
StaticAssert is a macro defined in disksim_global.h.
#define StaticAssert(c) switch (c) case 0: case (c):

The point is to detect a problem before the code is run, although the 
error message that is generated is confusing. Since sizeof(ioreq_event) 
and DISKSIM_EVENT_SIZE are known at compile time, I would assume the 
preprocessor does the evaluation and inserts the result in the place of 
the comparison.

Let's say the result is 0, ie the condition asserted to be true is in 
fact false.

Then this code will turn into:-
switch (0) case 0: case (0):

And gcc will complain.

The source reason for this failure is you are trying to compile disksim 
on a 64 bit system. disksim is not 64-bit clean, so compile this in 
32-bit mode by changing the gcc invocation to have the -m32 flag.

Hope this helps,
Michael.




More information about the Disksim-users mailing list