|
|
View previous topic :: View next topic |
Author |
Message |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
Compiler doesn’t catch the error. Bug? |
Posted: Tue Mar 25, 2008 4:04 pm |
|
|
Colleagues,
I’m not getting a compile-time error, when I expect it. This could be a bug. Take a look. I’ve declared a function to return int8, but commented out the return statement. Later, I call the function and compare the returned value to a constant.
Code: |
int8
spi_read_only()
{
int8 i;
int8 iRet; // return value received from SPI
output_high(SDO); // the host will receive 0xFF.
for (i=0;i<8;i++)
{
output_low(SCLK);
shift_left(iRet, 1, input(SDI));
output_high(SCLK);
}
// return iRet; // this should provoke a compile-time error
}
int8
mmc_send_command(...)
{
...
while ( (spi_read_only() != 0xFF) && iTimeoutCount < iMAX_TIMEOUT_COUNT)
{
// a comparison to an output of a function that doesn’t return anything should provoke another compile-time error
|
PCWH 3.240
16F690 _________________ Read the label, before opening a can of worms. |
|
|
Ttelmah Guest
|
|
Posted: Tue Mar 25, 2008 4:11 pm |
|
|
No, this is standard in C.
This is why (for example), the 'Main' function, in a standard C program (not CCS), which normally returns a status byte to the OS, can be omitted.
Falling off the end of a function, or having a return with no value, is defined to return 'garbage' in the C reference manual, but is not illegal.
Best Wishes |
|
|
|
|
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
|