cac001 0 Posted April 27, 2007 Report Share Posted April 27, 2007 (edited) /* File: bug20.C Target: PIC16F876A OS: WinXP, SP2 SourceBoostIDE: 6.70 Compiler: BoostC 6.70 Reproducible: always Expected behavior: compile without error Description: Statement: "unsigned long R;" results in "C:\Public\SourceBoost\bugs\bug20.c(58): error: failure". If target is PIC16F684 then compiles without error. PIC16F876A and PIC16F684 are the only targets that have been tried. */ #include <system.h> unsigned char div64by32(unsigned long &Quotient, unsigned long &Remainder, unsigned long DividenHI, unsigned long DividenLOW, unsigned long Divisor) { unsigned char count; // do a 64-bit divided by 32-bit integer division count = 64; Remainder = 0; Quotient = DividenLOW; // do not divide by zero if (Divisor) { do { Remainder = (Remainder << 1) | (DividenHI.31); DividenHI = (DividenHI << 1) | (Quotient.31); Quotient = (Quotient << 1); if (Remainder >= Divisor) { Remainder -= Divisor; Quotient |= 1; } } while (--count); } if (0 == DividenHI) { return (0); // Division valid } else { // divide overflow, Divisor too small for // result to fit in to a 32-bit value. return (1); // Division overflow } } unsigned long Q; unsigned long R; unsigned char result; void main() { result = div64by32(Q,R,0x7FFFffff,0xFFFFffff,0xFFFFffff); } Edited May 2, 2007 by cac001 Quote Link to post Share on other sites
Pavel 0 Posted September 3, 2007 Report Share Posted September 3, 2007 There is no compiler error here. For number of targets (like 16F687 R is used as a define in system.h). Preprocessor replaces your declaration directive with something that looks like 'unsigned long 0x0002;' and that's why you see this error. 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.