|
|
View previous topic :: View next topic |
Author |
Message |
rickydee
Joined: 03 Oct 2004 Posts: 2
|
enum compiler bug or poor programmer? |
Posted: Sat Nov 13, 2004 12:16 pm |
|
|
Hi,
I think I found a bug in the compiler. I'm using version 3.184. When I run this code, I get the compiler error"Expecting a , or )". However, if I place in comment the function prototypes (which are optional here), the compiler detects no error. If I keep the prototypes, but change the function enum parameters for int1, I get no error too.
Is this really a bug or am I a crazy?
Here's my code:
#include <18f458.h>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=8000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#define BATTERY_FOR_5V_STAT_PIN PIN_A2
#define BATTERY_FOR_5V_HDQ_PIN PIN_A3
#define BATTERY_FOR_12V_STAT_PIN PIN_A1
#define BATTERY_FOR_12V_HDQ_PIN PIN_A4
enum EBatterySource {eBatteryFor5V, eBatteryFor12V};
// function prototypes which to place in comment
void OutputHDQ(EBatterySource eBatterySource, int1 nBitToSend);
int1 InputHDQ(EBatterySource eBatterySource);
void OutputHDQ(EBatterySource eBatterySource, int1 nBitToSend)
{
if(eBatterySource == eBatteryFor5V)
{
if(nBitToSend == 1)
output_high(BATTERY_FOR_5V_HDQ_PIN);
else
output_low(BATTERY_FOR_5V_HDQ_PIN);
} else if(eBatterySource == eBatteryFor12V)
{
if(nBitToSend == 1)
output_high(BATTERY_FOR_12V_HDQ_PIN);
else
output_low(BATTERY_FOR_12V_HDQ_PIN);
} else
{
printf("Error in OutputHDQ(): eBatterySource = %d\r\n", eBatterySource);
}
}
int1 InputHDQ(EBatterySource eBatterySource)
{
if(eBatterySource == eBatteryFor5V)
{
return input(BATTERY_FOR_5V_HDQ_PIN);
} else if(eBatterySource == eBatteryFor12V)
{
return input(BATTERY_FOR_12V_HDQ_PIN);
} else
{
printf("Error in InputHDQ(): eBatterySource = %d\r\n", eBatterySource);
}
}
main()
{
while(1)
{
OutputHDQ(eBatteryFor5V, 0);
input(eBatteryFor5V);
}
} |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Nov 13, 2004 1:36 pm |
|
|
By default, the compiler is not case sensitive.
You can enable it by adding the line shown below, in bold.
However, I would never use identifers which differ only
by case. It's just too error prone.
#include <18f458.h>
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=8000000)
#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#case // This turns on case sensitivity |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|