word(...) is missing

Post Reply
vitor_boss
Posts: 61
Joined: Wed Apr 19, 2017 9:50 am

word(...) is missing

Post by vitor_boss » Wed May 31, 2017 12:31 pm

The word(hbyte, lbyte) function/makro don't work.

It could be found at:
https://github.com/arduino/Arduino/blob ... ino.h#L238

and

https://github.com/arduino/Arduino/blob ... th.cpp#L57

This is really messing with my code. Now I have this output: word(200, 41) = 41

Thank you in advance

User avatar
RogerClark
Posts: 6911
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: word(...) is missing

Post by RogerClark » Wed May 31, 2017 9:40 pm

Those are links to the AVR version.

Arduino ARM boards have an equivalent ?

zmemw16
Posts: 1417
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: word(...) is missing

Post by zmemw16 » Thu Jun 01, 2017 2:48 am

i think i'd be going with a #define or an in-line macro. local function???.
scope would be what ? global(to sketch) or local to setup/loop code / a_n_other_routines
i'd be curious as to what it actually is.
stephen

User avatar
RogerClark
Posts: 6911
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: word(...) is missing

Post by RogerClark » Thu Jun 01, 2017 3:12 am

Looks like the ARM version is similar (or the same ) as the AVR version

Code: Select all

extern uint16_t makeWord( uint16_t w ) ;
extern uint16_t makeWord( uint8_t h, uint8_t l ) ;

#define word(...) makeWord(__VA_ARGS__)

extern uint16_t makeWord( uint16_t w )
{
  return w ;
}

extern uint16_t makeWord( uint8_t h, uint8_t l )
{
  return (h << 8) | l ;
}
I wonder why this is part of the Arduino API

The first version takes a uint16_t and returns a uin16_t, so does not change its type. (I presume that the var that is returned is a copy)

The other version seems to be just doing

Code: Select all

(unit16_t)(((uint8_t)h << 8) | (uint8_t)l) ;
I presume they have all the complications of functions as they have 2 different function signatures



We currently have

Code: Select all

typedef unsigned int word;
in wirish.h

So there is a fair chance adding this macro will break something.

vitor_boss
Posts: 61
Joined: Wed Apr 19, 2017 9:50 am

Re: word(...) is missing

Post by vitor_boss » Thu Jun 01, 2017 9:41 pm

I had added manually and tested, is working fine.

I just came here to tell you guys that problem.

User avatar
RogerClark
Posts: 6911
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: word(...) is missing

Post by RogerClark » Thu Jun 01, 2017 9:45 pm

vitor_boss wrote:I had added manually and tested, is working fine.

I just came here to tell you guys that problem.
Thanks.

I will add it as an issue in github and let C and C++ gurus give some feedback

vitor_boss
Posts: 61
Joined: Wed Apr 19, 2017 9:50 am

Re: word(...) is missing

Post by vitor_boss » Fri Jun 02, 2017 12:12 am

RogerClark wrote:
vitor_boss wrote:I had added manually and tested, is working fine.

I just came here to tell you guys that problem.
Thanks.

I will add it as an issue in github and let C and C++ gurus give some feedback
The code is already on https://github.com/stm32duino/Arduino_C ... no/WMath.h

User avatar
RogerClark
Posts: 6911
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: word(...) is missing

Post by RogerClark » Fri Jun 02, 2017 12:26 am

But it doesnt work, so its an include path issue

Post Reply