PaulStoffregen
Well-known member
Compile times have become much slower in recent versions. Today I tracked the problem down to the improved map() function and C++14 friendly min() & max(), which were added in Teensyduino 1.37. This stuff currently lives in wiring.h starting around line 40.
https://github.com/PaulStoffregen/cores/blob/master/teensy3/wiring.h#L40
Actually the problem appears to be these 3 includes:
#include <type_traits>
#include <algorithm> // c++ min, max
#include <utility>
I must confess, I'm not a C++ template expert. Usually I just avoid templates and write in C-like syntax. So I could really use a hand here....
The new map() function is a huge improvement, especially since it automatically uses floating point if the input is a float or double. The template-based min() & max() solved long-standing complaints about the traditional Arduino preprocessor-based min() and max() breaking use of C++ features.
But slowing down compiling sketches and libraries by almost 2X is not good. Running g++ with -ftime-report shows it's spending all the extra CPU time parsing the complex headers! I'm hoping for suggestions of ways we might be able to keep these new features without the major slowdown for compiling all C++ Arduino code. Any ideas?
https://github.com/PaulStoffregen/cores/blob/master/teensy3/wiring.h#L40
Actually the problem appears to be these 3 includes:
#include <type_traits>
#include <algorithm> // c++ min, max
#include <utility>
I must confess, I'm not a C++ template expert. Usually I just avoid templates and write in C-like syntax. So I could really use a hand here....
The new map() function is a huge improvement, especially since it automatically uses floating point if the input is a float or double. The template-based min() & max() solved long-standing complaints about the traditional Arduino preprocessor-based min() and max() breaking use of C++ features.
But slowing down compiling sketches and libraries by almost 2X is not good. Running g++ with -ftime-report shows it's spending all the extra CPU time parsing the complex headers! I'm hoping for suggestions of ways we might be able to keep these new features without the major slowdown for compiling all C++ Arduino code. Any ideas?