GLBasic forum

Main forum => GLBasic - en => Topic started by: matchy on 2013-May-30

Title: Import or inline for uint32_t & byte
Post by: matchy on 2013-May-30
I'm wondering what are the data type replacements for these parameters, which are used in Arduino C;
IMPORT uint32_t get_color(byte r, byte g, byte b)
How do you import this function:?  :bed:
Code (glbasic) Select

uint32_t Color(byte r, byte g, byte b) {
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}

Title: Re: Import or inline for uint32_t & byte
Post by: bigsofty on 2013-May-30
Try...

Code (glbasic) Select
IMPORT "C" int Color(char r, char g, char b)

untested though.

Oh, and remember your REQUIRE if your not using command line stuff/inlines.
Title: Re: Import or inline for uint32_t & byte
Post by: MrTAToad on 2013-May-30
byte is usually either signed or unsigned char
uint32_t is unsigned int
Title: Re: Import or inline for uint32_t & byte
Post by: bigsofty on 2013-May-30
I could be wrong here but I think you are limited to the type of Types(:S) that IMPORT can use though? So, although these types are not ideal(you have to ignore the sign) I think they should still be usable with GLB.
Title: Re: Import or inline for uint32_t & byte
Post by: matchy on 2013-May-31
I actually tried unsigned int and char and it compiles but it's when it get's called I get an error:  :'(
undefined reference to `__GLBASIC__::Color(char, char, char)
Title: Re: Import or inline for uint32_t & byte
Post by: bigsofty on 2013-May-31
Ouch, could you post your test code?  :whistle:

BTW, I would just convert that little bit of code to inline or GLB syntax but you may be using this function as a template for a more complicated one I assume?
Title: Re: Import or inline for uint32_t & byte
Post by: matchy on 2013-May-31
Alright I am using the ASL command now as it's really the only bitwise operation.