Arduino uses gcc under the hood.

 

The error about the “for” could be a red herring. GCC is full of those.

 

Templates in C++ can be very sensitive to the proper declarations in place prior to a specialization of it.. The Arduino IDE plays games with how files are #included, which is one of the things I do not like about it, it makes things easier for beginners, at the expense on control for power users.

 

You syntax looks correct. (as it ought to since it compiles in another environment). Try moving those lines around within the source file, or even putting them in a header files in an inline function, just short term, in an attempt to get a more clear error message.

 

 

From: alex--- via TriEmbed
Sent: Tuesday, April 21, 2020 5:33 PM
To: [email protected]
Subject: [TriEmbed] C++ class templates in Arduino - problems

 

Anyone familiar with class templates? Code which has no problems under clang-1100.0.33.16 appears to have trouble under whatever Arduino 1.8.9 is using as a compiler.

Take these two lines as an example:

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);

On Arduino, it complains the ‘for’ on the second line was unexpected. The compiler must be doing something wrong with substituting code on line 1 and losing the ‘;’ perhaps. But why?

For those with time:
Arduino code is here:
https://github.com/quarterturn/simple-wireframe

Linux or OSX command line code is here:
https://github.com/quarterturn/wireframe

What the code does is render a 3D model as a wireframe, using surface normals for back surface culling, as well as a z-buffer for hidden line removal. On the Arduino, should I ever get it working, it will send a vector list to an Arduino Due, which will use it to draw the image on an oscilloscope in XY mode.

I gotta get off Arduino. Only so many systicks in a day though.

Alex



_______________________________________________
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

Reply via email to