2DeskLib won't build with DDE5 - compiler bug?
Rick Murray (539) 13850 posts |
[gah! idiot typo in the subject line…] Hi, As the subject says. Builds just fine with DDE24, however when using DDE25, the “Event” code aborts with the message:
The line in question is:
(event_pollmask was earlier defined as a union – what is it expecting, “= { 0 }” ?) I have created a listing file showing what the compiler “sees” here: http://www.heyrick.co.uk/random/event.txt If I remove the error message line in the newer listing, the rest of the content is identical to the listing created by the DDE24 compiler. I can get it to build by removing the “= 0” part of the line so it isn’t a critical issue, however… Why is this happening? Or, more specifically, why is the newer compiler having differently to the previous with the same source? For reference, compiler options are: cc -c -ffahi -list -depend !Depend -throwback -D_DeskLib_Event -I,C: ^.c.Event -o o.Event |
Theo Markettos (89) 919 posts |
You’re right:
(as ever, clang’s error messages are more helpful). If you put it in { } then it compiles. If you remove the = 0 part then you aren’t initialising the global variable – with unknown consequences for whatever it gets used for. To be explicit you can also do: |
Jeffrey Lee (213) 6048 posts |
Not true – the spec says that objects with static storage duration (i.e. globals, statics) will be zero-initialised by default. |
Theo Markettos (89) 919 posts |
Yes, you’re right – since it’s global it’ll get put in the zero-initialised segment. However I think it’s generally good practice to do explicit initialisation and not rely on the behaviour of the runtime system – means you can read the code with having to understand the scope. |