Did it compile if you commented out the template stuff and just tried: int* foo = new int[42]; That would tell you if it was the dynamic array issue vs something not right with the templates. I’d bet big money that is not any issue with the compiler not supporting templates, it appears to be basic use of templates, and gcc has supported that for a few decades. Here is another test, try making your own template class, and attempt the same allocation: template <typename T> class TestVec { public: TestVec(T t) {} }; VecTest<unsigned char> *frameBuffer = new TestVec <unsigned char>[imageWidth * imageHeight]; for (uint32_t i = 0; i < imageWidth * imageHeight; ++i) frameBuffer[i] = TestVec <unsigned char>(255); By the way, even if “Vec” class is a single byte, your allocation would require 16 *megabytes*. That’s not going to work on Arduino AVR. It might even be the case that since the int type on Arduino AVR is 16 bit, and also I think that “size_t” type is unsigned 16 bit. The compiler could be freaking out, not knowing how to handle a number that large for the allocation. I’d try getting it working first with a really small number of array elements. From: Alex Davis via TriEmbed > 2. Re: C++ class templates in Arduino - problems (Jon Wolfe) > 3. Re: C++ class templates in Arduino - problems (Robert Mackie) Simplifying the program to just this: #include "geometry.h" const uint32_t imageWidth = 4095; const uint32_t imageHeight = 4095; // define the frame-buffer and the depth-buffer. Initialize depth buffer // to far clipping plane. Vec3<unsigned char> *frameBuffer = new Vec3<unsigned char>[imageWidth * imageHeight]; for (uint32_t i = 0; i < imageWidth * imageHeight; ++i) frameBuffer[i] = Vec3<unsigned char>(255); // ---------------------------------------------- // setup // ---------------------------------------------- void setup() { } // ---------------------------------------------- // main loop // ---------------------------------------------- void loop() { } still results in the same compile error. Moving the new line into the include gives the same error. Alex -- "The theater of noise is proof of our potential." |\ | (¯ \/ |¯\ |V| |\ ¯|¯ |¯) | \/ | | | |¯\ (¯ /¯ /\ |V| |-||_ (_ /\ |_/ @| | |-| | | \ | /\ |^| | |_/ (_ . \_ \/ | | You won't find me on Facebook. _______________________________________________ Triangle, NC Embedded Computing mailing list To post message: [email protected] List info: http://mail.triembed.org/mailman/listinfo/triembed_triembed.org TriEmbed web site: http://TriEmbed.org To unsubscribe, click link and send a blank message: mailto:[email protected]?subject=unsubscribe |
_______________________________________________ Triangle, NC Embedded Computing mailing list
To post message: [email protected] List info: http://mail.triembed.org/mailman/listinfo/triembed_triembed.org TriEmbed web site: http://TriEmbed.org To unsubscribe, click link and send a blank message: mailto:[email protected]?subject=unsubscribe
