Jump to content

rbairos

EstablishedMember
  • Content Count

    5
  • Joined

  • Last visited

Everything posted by rbairos

  1. Hi guys. Porting some code, and coming across several small changes I had to make in order to make it compile. Thought I'd list one or two here and see if they are known limitations, etc. Cheers Rob issue#1 doesn't work: Client::Client(char s) : _sock(s) { } works: Client::Client(char s) { _sock = s; }
  2. Hi All. This is very frustrating: { int i = 5; float f; f = i; } causes: mainloop.c mainloop.c(404): error: can't convert 'signed int' to 'float' mainloop.c(404:4): error: failed to generate expression If I try: f = (float)i; results in: mainloop.c mainloop.c(404:13): internal error: can't assign operand to temp var mainloop.c(404:6): error: failed to generate expression mainloop.c(404:6): error: invalid operand '(float)i' mainloop.c(404:4): error: failed to generate expression Any help appreciated.
  3. Wow, I just spent a week pinpointing a similar bug. Here it is, if it sheds any light. In a nutshell, all four methods are overwriting the first byte of the array, instead of writing into first, second, third, fourth. class foo { public: char *first() { return (char *)&data[0]; } char *second() { return (char *)&data[1]; } char *third() { return (char *)&data[2]; } char *fourth() { return (char *)&data[3]; } char *getData() { return data; } private: char data[4]; }; void main() { class foo f; *f.first() = 1; // stuffs data[0] *f.second() = 2; // stuffs data[0], not data[1] *f.third() = 3; // stuffs data[0], not data[2] *f.fourth() = 4; // stuffs data[0], not data[3] char *data = f.getData(); char a = data[0]; // returns 4, instead of 1 char b = data[1]; // returns 0, instead of 2 char c = data[2]; // returns 0, instead of 3 char d = data[3]; // returns 0, instead of 4 } Incidentally, if I change the function signature to: char *first() { return &data[0]; } char *second() { return &data[1]; } char *third() { return &data[2]; } char *fourth() { return &data[3]; } I get a compiler errors: mainloop.c(12): error: can't convert 'class foo' to 'unsigned char*' mainloop.c(12:18): error: failed to generate expression mainloop.c(13): error: can't convert 'class foo' to 'unsigned char*' mainloop.c(13:19): error: failed to generate expression mainloop.c(14): error: can't convert 'class foo' to 'unsigned char*' mainloop.c(14:18): error: failed to generate expression mainloop.c(15): error: can't convert 'class foo' to 'unsigned char*' mainloop.c(15:19): error: failed to generate expression Why its treating member 'data' as 'class foo' is also strange and may be a clue. Any help appreciated. Thanks, Rob.
  4. Hi Sorry, Ive searched the forums, and not entirely sure on the answer. Does anyone which endian Boost C++ uses for the PIC18F25J10 ? Given the following code: ------------------------------ union{ unsigned long four; unsigned char one[4]; }test; test.four = 0x44332211; --------------------------------- Ive deteremined: one[0] = 0x11; one[1] = 0x22; one[2] = 0x33; one[3] = 0x44; So, this means Little Endian correct? (sorry Im just juggling so many small details on this project, this type of question trips me up). Thanks, Rob.
  5. Hi Dave. I just downloaded the C++ compiler and noticed it did not have the PIC16F1825 as advertised. After much head scratching, I realized I had to install the above zip file. Why not roll it into the current installation? (Also, when I use the project Wizard, I only have a choice of 4 or 5 target devices in the pulldown menu instead of the full list, not sure why.) Cheers, Rob.
×