Odd message from CC with zero-length char definitions
Rick Murray (539) 13747 posts |
CC version 5.82 I had a fat fingered moment and defined a char as having zero elements (instead of 9, 8+term). The definition was: char blahwhatever[0] = ""; Norcroft replied with: Line Type Description 707 Error expected ';' or ',' - inserted ';' before '"$"' 707 Warning no side effect in void context: <string constant> I can’t help but think that the error message is a bit of gibberish, and something to the effect of “char arrays cannot be empty, dumbass” might be more appropriate than… whatever |
Chris Mahoney (1684) 2160 posts |
I’m guessing that it’s supposed to represent an anonymous string. For what it’s worth, when you make the same mistake in clang it doesn’t generate any warning at all. But if you specify some string content: test.c:3:26: warning: initializer-string for char array is too long [-Wexcess-initializers] char blahwhatever[0] = "Hello"; ^~~~~~~ |