FrankGe 0 Posted January 3, 2005 Report Share Posted January 3, 2005 Environment: Sourceboost 5.8 BoostC 1.9 OS: XP sp2 PIC: 16F877a Compile and debug this code only the first send in main() works. #include <system.h> rom char *msg = "Message"; void send(const char c) { char b = c; } void send(const char* s) { while (*s) send(*s++); } void main() { send ('a'); send ("Test"); send (msg); } Quote Link to post Share on other sites
Pavel 0 Posted January 3, 2005 Report Share Posted January 3, 2005 Try to edit your code to look more like: #include <system.h> rom char *msg = "Message"; void send(const char c) { char b = c; } void send(rom char* s) { } void main() { send ('a'); send ((rom char*)"Test"); send (msg); } Regards, Pavel Quote Link to post Share on other sites
FrankGe 0 Posted January 3, 2005 Author Report Share Posted January 3, 2005 Try to edit your code to look more like: #include <system.h> rom char *msg = "Message"; void send(const char c) { char b = c; } void send(rom char* s) { } void main() { send ('a'); send ((rom char*)"Test"); send (msg); } Regards, Pavel <{POST_SNAPBACK}> Pavel, I changed my code to void send(rom char* s) { while (*s) send(*s++); } now i've got a compilation error error invalid operation applied to operand with 'rom' storage type. when I change my code to void send(rom char* s) { char i = 0; while(s) { send(s); i++; } } it works fine, but why can't I use pointers ? Frank Quote Link to post Share on other sites
Dave 0 Posted January 3, 2005 Report Share Posted January 3, 2005 FrankGe, I would recommend code the function this way: void send(rom char* s) { char c; char i = 0; while ( c = s[ i ] ) { send(c); i++; } } This only computes and use once the index value, making the code length much shorted. Regards Dave Quote Link to post Share on other sites
FrankGe 0 Posted January 3, 2005 Author Report Share Posted January 3, 2005 Pavel, Dave, I've got now a new project without "rom char * " but it doesn't work #include <system.h> void send(char c) { char b = c; } void send(char* s) { char c; char i = 0; while(c = s) { send©; i++; } } void main() { while (1) { send ('a'); send ("Test"); } } Frank. Quote Link to post Share on other sites
Guest Joe Posted January 3, 2005 Report Share Posted January 3, 2005 You've absolulutly right, this does appear to be a bug. I used the simulator to test your code and both send(..) calls routed to the single char option. However, changing your send calls like this: send ('a'); send ( (char*) "Test" ); makes it work for now until this bug is fixed. joe Quote Link to post Share on other sites
Pavel 0 Posted January 5, 2005 Report Share Posted January 5, 2005 You've absolulutly right, this does appear to be a bug. I used the simulator to test your code and both send(..) calls routed to the single char option. However, changing your send calls like this: send ('a'); send ( (char*) "Test" ); makes it work for now until this bug is fixed. joe <{POST_SNAPBACK}> Fixed in BoostC 1.9.2 Regards, Pavel Quote Link to post Share on other sites
FrankGe 0 Posted January 5, 2005 Author Report Share Posted January 5, 2005 Hello, OS: XP SP2 Sourceboost 5.8 BOOSTC 1.9.2 There is still a problem with "rom char *" #include <system.h> rom char *msg = "Message"; void send(const char c) { char b = c; } void send(const char* s) { char c; char i = 0; while(c = s) { send©; i++; } } void main() { while (1) { send ('a'); send ("Test"); send (msg); } } When I have to cast to "rom char *" I think the compiler should give me an error. because it doesn't work. Frank Quote Link to post Share on other sites
Pavel 0 Posted January 6, 2005 Report Share Posted January 6, 2005 ...When I have to cast to "rom char *" I think the compiler should give me an error. because it doesn't work. Did you want to say "cast from 'rom char*' to 'const char*'"? I don't think compiler should trow an error for such conversions (some general come may for example store rom pointer in a variable) however a warning for such conversion may be a good idea. Regards, Pavel Quote Link to post Share on other sites
FrankGe 0 Posted January 6, 2005 Author Report Share Posted January 6, 2005 Hello Pavel The last example doesn't work. The function send(msg) does nothing. Look with the debugger. Frank Quote Link to post Share on other sites
Pavel 0 Posted January 7, 2005 Report Share Posted January 7, 2005 The last example doesn't work. The function send(msg) does nothing. Look with the debugger. Of course it won't work. A 'rom' pointer casted to non-rom can't be used anymore unless it gets casted back to 'rom' type. Regards, Pavel Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.