mapbox/tilelive-s3

Build fails with ISO C++ forbids variable-size array ‘row_pointers’

Closed this issue · 1 comments

Build log:

~  ▶ npm install tilelive-s3 --verbose
npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli   '/Users/willwhite/.nvm/v0.4.12/bin/npm',
npm verb cli   'install',
npm verb cli   'tilelive-s3',
npm verb cli   '--verbose' ]
npm info using npm@1.0.106
npm info using node@v0.4.12
npm verb config file /Users/willwhite/.npmrc
npm verb config file /Users/willwhite/.nvm/v0.4.12/etc/npmrc
npm verb config file /Users/willwhite/.nvm/v0.4.12/lib/node_modules/npm/npmrc
npm verb caching /Users/willwhite/node_modules/tilestream/package.json
npm verb loadDefaults tilestream@1.0.0
npm verb into /Users/willwhite [ 'tilelive-s3' ]
npm verb cache add tilelive-s3
npm verb cache add [ 'tilelive-s3', null ]
npm verb parsed url { pathname: 'tilelive-s3',
npm verb parsed url   href: 'tilelive-s3' }
npm info addNamed [ 'tilelive-s3', '' ]
npm verb addNamed [ null, '' ]
npm verb GET tilelive-s3
npm verb raw, before any munging tilelive-s3
npm verb url resolving [ 'https://registry.npmjs.org/',
npm verb url resolving   './tilelive-s3' ]
npm verb url resolved https://registry.npmjs.org/tilelive-s3
npm verb etag "9WJAU9QB89ALWJ5CYOZNF8AEW"
npm verb etag tilelive-s3 from cache
npm verb GET tilelive-s3/0.0.1
npm verb raw, before any munging tilelive-s3/0.0.1
npm verb url resolving [ 'https://registry.npmjs.org/',
npm verb url resolving   './tilelive-s3/0.0.1' ]
npm verb url resolved https://registry.npmjs.org/tilelive-s3/0.0.1
npm verb etag "9WJAU9QB89ALWJ5CYOZNF8AEW"
npm verb etag tilelive-s3/0.0.1 from cache
npm verb bin dist [ '0.4-ares1.7.4-ev4.4-openssl0.9.8r-v83.1.8.26-darwin-11.3.0',
npm verb bin dist   { shasum: '9ec57cfba1bf93a63b1fcb2bab7af4cebef48f0f',
npm verb bin dist     tarball: 'http://registry.npmjs.org/tilelive-s3/-/tilelive-s3-0.0.1.tgz' } ]
npm verb has wscript [ undefined,
npm verb has wscript   { file: '/Users/willwhite/.npm/tilelive-s3/0.0.1/package/package.json',
npm verb has wscript     contributors: false,
npm verb has wscript     serverjs: false,
npm verb has wscript     wscript: true } ]
npm verb caching /Users/willwhite/.npm/tilelive-s3/0.0.1/package/package.json
npm verb loadDefaults tilelive-s3@0.0.1
npm info into /Users/willwhite tilelive-s3@0.0.1
npm info installOne tilelive-s3@0.0.1
npm info unbuild /Users/willwhite/node_modules/tilelive-s3
npm verb from cache /Users/willwhite/.npm/tilelive-s3/0.0.1/package/package.json
npm verb mkdir (expected) error ENOENT, No such file or directory '/Users/willwhite/node_modules/___tilelive-s3.npm'
npm verb mkdir done: /Users/willwhite/node_modules/___tilelive-s3.npm 755
npm verb unpack_ uid, gid [ undefined, undefined ]
npm verb unpackTarget /Users/willwhite/node_modules/tilelive-s3
npm verb gunzed /Users/willwhite/node_modules/___tilelive-s3.npm/package
npm verb rm'ed /Users/willwhite/node_modules/tilelive-s3
npm verb renamed [ '/Users/willwhite/node_modules/___tilelive-s3.npm/package',
npm verb renamed   '/Users/willwhite/node_modules/tilelive-s3' ]
npm verb has wscript [ undefined,
npm verb has wscript   { file: '/Users/willwhite/node_modules/tilelive-s3/package.json',
npm verb has wscript     contributors: false,
npm verb has wscript     serverjs: false,
npm verb has wscript     wscript: true } ]
npm verb caching /Users/willwhite/node_modules/tilelive-s3/package.json
npm verb loadDefaults tilelive-s3@0.0.1
npm info preinstall tilelive-s3@0.0.1
npm verb unsafe-perm in lifecycle true

> tilelive-s3@0.0.1 preinstall /Users/willwhite/node_modules/tilelive-s3
> node-waf clean || true; node-waf configure build

Nothing to clean (project not configured)
Setting srcdir to                        : /Users/willwhite/node_modules/tilelive-s3 
Setting blddir to                        : /Users/willwhite/node_modules/tilelive-s3/build 
Checking for program g++ or c++          : /usr/bin/g++ 
Checking for program cpp                 : /usr/bin/cpp 
Checking for program ar                  : /usr/bin/ar 
Checking for program ranlib              : /usr/bin/ranlib 
Checking for g++                         : ok  
Checking for node path                   : not found 
Checking for node prefix                 : ok /Users/willwhite/.nvm/v0.4.12 
Checking for libpng at /usr/X11          : yes 
'configure' finished successfully (0.149s)
Waf: Entering directory `/Users/willwhite/node_modules/tilelive-s3/build'
[1/3] cxx: src/reader.cpp -> build/default/src/reader_1.o
[2/3] cxx: src/decode.cpp -> build/default/src/decode_1.o
../src/reader.cpp: In member function ‘virtual bool PNGImageReader::decode()’:
../src/reader.cpp:83: error: ISO C++ forbids variable-size array ‘row_pointers’
Waf: Leaving directory `/Users/willwhite/node_modules/tilelive-s3/build'
Build failed:  -> task failed (err #1): 
    {task: cxx reader.cpp -> reader_1.o}
npm info tilelive-s3@0.0.1 Failed to exec preinstall script
npm ERR! error installing tilelive-s3@0.0.1 Error: tilelive-s3@0.0.1 preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! error installing tilelive-s3@0.0.1 `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! error installing tilelive-s3@0.0.1     at ChildProcess.<anonymous> (/Users/willwhite/.nvm/v0.4.12/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing tilelive-s3@0.0.1     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing tilelive-s3@0.0.1     at ChildProcess.onexit (child_process.js:192:12)
npm info unbuild /Users/willwhite/node_modules/tilelive-s3
npm verb from cache /Users/willwhite/node_modules/tilelive-s3/package.json
npm info preuninstall tilelive-s3@0.0.1
npm info uninstall tilelive-s3@0.0.1
npm verb unbuild tilelive-s3@0.0.1 [ true,
npm verb unbuild tilelive-s3@0.0.1   '/Users/willwhite/node_modules',
npm verb unbuild tilelive-s3@0.0.1   '/Users/willwhite/node_modules' ]
npm info postuninstall tilelive-s3@0.0.1
npm verb installOne cb tilelive-s3@0.0.1
npm ERR! tilelive-s3@0.0.1 preinstall: `node-waf clean || true; node-waf configure build`
npm ERR! `sh "-c" "node-waf clean || true; node-waf configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the tilelive-s3@0.0.1 preinstall script.
npm ERR! This is most likely a problem with the tilelive-s3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf clean || true; node-waf configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls tilelive-s3
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 11.3.0
npm ERR! command "node" "/Users/willwhite/.nvm/v0.4.12/bin/npm" "install" "tilelive-s3" "--verbose"
npm ERR! cwd /Users/willwhite
npm ERR! node -v v0.4.12
npm ERR! npm -v 1.0.106
npm ERR! code ELIFECYCLE
npm verb exit [ 1, true ]
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/willwhite/npm-debug.log
npm not ok

should be fixed by 4d03aa2. I'm offline tomorrow but in the odd case that this is not fixed you could apply this:

diff --git a/src/reader.cpp b/src/reader.cpp
index d6604ec..b9e0bfd 100644
--- a/src/reader.cpp
+++ b/src/reader.cpp
@@ -80,13 +80,14 @@ bool PNGImageReader::decode() {
         surface = (unsigned int*)malloc(width * height * 4);
         assert(surface);

-        png_bytep row_pointers[height];
+        png_bytep * row_pointers = new png_bytep[height];
         for (unsigned i = 0; i < height; i++) {
             row_pointers[i] = (unsigned char *)surface + (i * rowbytes);
         }

         // Read image data
         png_read_image(png, row_pointers);
+        delete[] row_pointers;

         png_read_end(png, NULL);