From d37757900b8217880f74deb0df6298f36e5ef32c Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 14 Oct 2011 21:57:12 +0200 Subject: [PATCH] kinect_upload_fw: fix a mingw32 compilation error MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When compiling with i586-mingw32msvci-g++ We get these errors: kinect_upload_fw.c: In function ‘int main(int, char**)’: kinect_upload_fw.c:236: error: jump to label ‘cleanup’ kinect_upload_fw.c:179: error: from here kinect_upload_fw.c:185: error: crosses initialization of ‘uint32_t addr’ kinect_upload_fw.c:238: error: jump to label ‘fail_libusb_open’ kinect_upload_fw.c:155: error: from here kinect_upload_fw.c:185: error: crosses initialization of ‘uint32_t addr’ Declaring and initializing a variable in the same statement after a goto is allowed in C but not in C++; look at C++ specification Section 6.7 Paragraph 3. (http://www.kuzbass.ru:8086/docs/isocpp/stmt.html#stmt.dcl) Work around that by splitting 'addr' declaration and initialization. --- kinect_upload_fw/kinect_upload_fw.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kinect_upload_fw/kinect_upload_fw.c b/kinect_upload_fw/kinect_upload_fw.c index 21bdef9..80be29b 100644 --- a/kinect_upload_fw/kinect_upload_fw.c +++ b/kinect_upload_fw/kinect_upload_fw.c @@ -182,7 +182,11 @@ int main(int argc, char** argv) { res = get_reply(); // I'm not sure why we do this twice here, but maybe it'll make sense later. seq++; - uint32_t addr = 0x00080000; + // Split addr declaration and assignment in order to compile as C++, + // otherwise this would give "jump to label '...' crosses initialization" + // errors. + uint32_t addr; + addr = 0x00080000; unsigned char page[0x4000]; int read; do { -- 2.1.4