Open GoogleCodeExporter opened 9 years ago
This version of wiring.h removes all the dangerous macros that use a parameter
more
than once and replaces them with C++ templates.
The C macros are commented out, but are in an ifdef that would only include
them in C
programs. No arduino libraries written in C seem to rely on these functions, so
it
would probably be best to leave them out of C.
Considering that Arduino is supposed to be easy to pick up, I think this is a
good idea
Original comment by gabebear@gmail.com
on 6 Jul 2009 at 2:37
Attachments:
Original comment by dmel...@gmail.com
on 14 Jul 2009 at 10:03
What do these templated functions do if you pass them parameters of different
types (e.g. an int and a float)?
Original comment by dmel...@gmail.com
on 15 Aug 2009 at 8:38
Original comment by dmel...@gmail.com
on 11 Oct 2011 at 3:39
I've been out of the loop here for awhile, but I can't imagine these templates
having any problem with any sane type. I haven't been using Arduino much
lately. I could spin back up if you want me to do something though.
As a C/C++/ObjC programmer these kinds of problems really annoy me so I would
like to get it fixed even though I've moved to other platforms.
Original comment by gabebear@gmail.com
on 11 Oct 2011 at 4:44
I think that using C++ templates is a VERY BAD idea.
There are other ways to handle this that work for both C and C++.
Remember that these headers files are being use for both C and C++ so any
solution
really needs to work for both.
The problem is that the existing macros are too wimpy.
Here is the proper way to do this:
http://arduino.cc/forum/index.php/topic,84364.msg640438.html#msg640438
Original comment by bperry...@gmail.com
on 9 Jun 2012 at 6:49
no, don't use DEFINE for macros and constants in c++ mode as it _breaks_ code.
two examples:
struct vector2{ /*..*/ };
float abs(vector2) { /*..*/ } // breaks function overloading
and
namespace some_ns { const float PI=3.14....; } // invades all namespaces
because of these defines i'm currently forced to use a lot of workarounds
Original comment by markus.w...@gmail.com
on 18 Aug 2013 at 12:47
Original issue reported on code.google.com by
gabebear@gmail.com
on 6 Jul 2009 at 5:01Attachments: