Jump to content

Problem With Typedef'd Struct Pointers As Parameters


Recommended Posts

Hi there,

 

I am porting some code from HITECH and have come across a small problem.

 

BoostC V7.01

PIC18F2525

Windows XP

 

The following code gives a compiler error:

SourceBoostTest.c(15:10): error: arguments of 'TestProc' don't match the parameters of call.

 

If you change TTestStruct from a struct to a char it compiles OK.

If you don't use typedef, it compiles OK.

 

//******************************

#include <system.h>

 

typedef struct teststruct {

unsigned char a;

} TTestStruct;

 

typedef TTestStruct* PTestStruct;

 

void TestProc(PTestStruct aPtr)

{

}

 

void main(void)

{

TestProc(0);

while(1);

}

//******************************

 

Thanks,

 

Andy Leiper

IET Ltd

Link to post
Share on other sites

That code compiled ok on Linux but it might be more correct to type cast the 0 passed with the data type that TestProc is expecting. The 0 should be promoted to an integer which TestProc is not expecting.

 

Instead of:

 

TestProc(0);

 

Use:

 

TestProc((PTestStruct)0);

 

This solved the problem with V6.89. I'll admit that I'm glad the SourceBoost complier flagged this as a problem.

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...