Jump to content

Bug: Typedef Types And Identifier Problems?


Recommended Posts

Bug description:

Compiler reports errors with some operations when you typedef a type, ie:

typedef unsigned char byte;

and you also have an identifies which starts with all characters of that typedef, ie:

byte byte_data;

 

Steps to reproduce:

Please see the CODE box. As it stands the compiler will generate erros. If you then delete the 'b' of 'byte' from #define STORAGE_B byte, a different error occurs. If you then delete the 'w' of 'word' from #define STORAGE_W word , the code will compile and link WITHOUT ERRORS! Your comments please.

Is it an compiler problem withs resolving the identifiers from the symbol table? The typedefs are substrings (first part == prefix) of the other declarations - storage and functions.

 

// BoostC Compiler options -v -W2 -Oa -Su -t PIC18F4550
#include <system.h>
//------------------------------------------------------
// As is generates an "error: missing semicolon" and an
// "error: failure" for line byte_to_send--; 
// in function byte_byte
// If the 'b' of 'byte' is deleted in the line
//   #define STORAGE_B byte
// a different error is generated.
// If the 'w' of 'word' is deleted in the line
//   #define STORAGE_W word
// this program will compile WITHOUT ANY ERRORS !!!!
// Is there an internal problem within the compiler when
// a symbol lookup is performed? ie. what happens
// with:
// byte
// byte_byte
// byte_to_send
// i think 'byte' may be returned first???

#define STORAGE_B       byte
#define STORAGE_W       word
typedef unsigned char   STORAGE_B;           // 8-bit
typedef unsigned int    STORAGE_W;           // 16-bit
//------------------------------------------------------
STORAGE_B len=64;
void byte_byte(void);
void word_byte(void);
//------------------------------------------------------
void byte_byte()
{
   STORAGE_B byte_to_send=len;
   while(byte_to_send) 
     byte_to_send--;
}
//-----------------------------------------------------
void word_byte()
{    
   STORAGE_W byte_to_send=len;
   while(byte_to_send) 
     byte_to_send--;
}
//------------------------------------------------------
void main()
{
 byte_byte();
 word_byte();
}
// END

Expected behaviour:

I would expect the example code to compile without error.

 

Is the problem 100% reproduceable:

Errors and subsequent errors from fixing one problem occur in other places or reveal further warnings and error - this was found as I converted Microchip's USB firmware to compile with BoostC.

 

IDE version: SourceBoost IDE version 6.35

Compiler: BoostC Compiler

Compiler version: 6.35

Target device: PIC18F4550

OS: : XP Pro SP2

 

Comments:

I think I found that changing the byte_to_send-- to a --byte_to_send may produce a different error or no error at all??

 

G

Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...