Jump to content

Fail To Compile


Recommended Posts

Hi,

 

I am working on a complex program and used VC++ to test before compiling to a PIC. However now when compiling using the SB compiler it fails when compiling:

unsigned char FAT_type(BIOS_PARAM_BLOCK *,unsigned long *);
void main()
{
    BIOS_PARAM_BLOCK *bpb;
    unsigned long CountOfClusters;

    FAT_type(bpb,&CountOfClusters);
}

 

if I add a return varible it compiles OK

unsigned char FAT_type(BIOS_PARAM_BLOCK *,unsigned long *);
void main()
{
   BIOS_PARAM_BLOCK *bpb;
   unsigned long CountOfClusters;
   unsigned char c;

   c = FAT_type(bpb,&CountOfClusters);
}

 

This seems like a bug (non-ansi) and will cause a lot of extra editing.

Link to post
Share on other sites

carolyn,

 

I can't reproduce the problem.

 

The following code compiles and linker for targets PIC16F877A or PIC18F8720.

 

#include <system.h>

typedef struct
{
    int var;
} BIOS_PARAM_BLOCK;

unsigned char FAT_type(BIOS_PARAM_BLOCK *,unsigned long *);

void main()
{
   BIOS_PARAM_BLOCK *bpb;
   unsigned long CountOfClusters;

   FAT_type(bpb,&CountOfClusters);
}

unsigned char FAT_type(BIOS_PARAM_BLOCK *bpb , unsigned long *cc )
{
    return 0;
}

 

Regards

Dave

Link to post
Share on other sites

I am sorry but it seems that the fault was not due to the return but because of a typedef I had in a include file. By including the typedef FAT it seems that the FAT in FAT_type gets affected.

 

#include <system.h>


typedef struct
{
    int var;
} BIOS_PARAM_BLOCK;

unsigned char FAT_type(BIOS_PARAM_BLOCK *,unsigned long *);

typedef unsigned short FAT;   //************

void main()
{
   BIOS_PARAM_BLOCK *bpb;
   unsigned long CountOfClusters;

   FAT_type(bpb,&CountOfClusters);
}

unsigned char FAT_type(BIOS_PARAM_BLOCK *bpb , unsigned long *cc )
{
    return 0;
}

 

Carolyn

Link to post
Share on other sites

Also found that the array fails to compile with auto-initialisation.

 

#include <system.h>

typedef struct {
unsigned long MaxDskSize;
char ClusterSize;
} DISKSIZETOCLUSTERSIZE;

void main()
{
DISKSIZETOCLUSTERSIZE ClusterSizeTable16[] = {{0,0}};
}

 

Carolyn

Link to post
Share on other sites
This looks like the same problem I reported in posting #7711

Looks like the same thing to me too.

 

It took me awhile to find it so here is a link to BeanBrains original post

 

Another short example:

#include <system.h>
/* 
** typedef substitution bug
**
** If a type is defined that matches the
** beginning of a function name then the
** function invocation fails to compile.
**
** Additional observation:
** 
** When a typedef matches a function
** declaration the error message is
** not very informative:
** 
** "bug.c(21): error:  failure"
**
*/

typedef unsigned short word;

void word_function(void) {};

void main()
{
 word_function();
}

Edited by cac001
Link to post
Share on other sites
Another short example:

#include <system.h>
/* 
** typedef substitution bug
**
** If a type is defined that matches the
** beginning of a function name then the
** function invocation fails to compile.
**
** Additional observation:
** 
** When a typedef matches a function
** declaration the error message is
** not very informative:
** 
** "bug.c(21): error:  failure"
**
*/

typedef unsigned short word;

void word_function(void) {};

void main()
{
 word_function();
}

 

Suggestion: the preprocessor pattern matching machine must reject partial matches where a non-token character (non-blank, non-operator and a few more non-) closes the otherwise matching pattern in source file.

 

This is not a point to be overlooked: CCS C has a very similar (symmetrical) problem with recursive substitution. You cannot write "#pragma byte KBD_CTRL = PORTA", despite PORTA has been correctly #defined: you have to use explicit addresses. Net result: work twice and introduce more hard-to-find mistakes in porting.

Edited by DL1968
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...