Jorge Arellano Cid wrote:
Hi Glyn,
On Mon, Jan 02, 2006 at 09:36:05PM +0000, Glyn Kennington wrote:
[...] downloads.cc: In function 'void read_req_cb(int, void*)': downloads.cc:915: error: jump to label 'end' downloads.cc:901: error: from here downloads.cc:907: error: crosses initialization of 'DLAction action' [...]
Putting the DlAction block within its own scope solves the problem, but I'm sure it's not as simple as that.
Really weird. What compiler are you using?
gcc 4.0.3, in Debian testing. I get the same result with gcc 3.3.6.
From a distance look like the compiler gets confused trying to catch uninitialized variables.
There's an entry about it in the g++ FAQ: http://theory.uwinnipeg.ca/gnu/libg++/g++FAQ_42.html The draft standard does not allow a goto or a jump to a case label to skip over an initialization of a variable or a class object. I'm quite surprised that nobody else has got this error, though.
Try declaring 'action' with the other vars with a value:
char *cmd = NULL, *url = NULL, *dl_dest = NULL; + DLAction action = DL_ABORT;
- DLAction action = dl_win->check_filename(&dl_dest); + action = dl_win->check_filename(&dl_dest);
That compiles and runs OK.
Did you get it to work right?
Yes, thanks - with either your suggestion, or the extra set of braces, it works correctly. Glyn