Jump to content
Sign in to follow this  
BrownFrog

Link Error: Mismatch Of Extern Data Types

Recommended Posts

I've been trying to compile the Microchip TCP/IP stack for an Olimex PIC_MINI_WEB device, and after many syntax alterations to suit BoostC all the source files compile OK but I struck this error at link time:

 

 

failure

Error:Linking externs failed, mismatch of data types for variable:'AppConfig'

 

 

I've traced the problem to a nested struct/union/struct (WORD_VAL). Here is code that triggers the problem:

 

----- test1.h -----

#include <system.h>

 

typedef unsigned char BYTE;

typedef unsigned short WORD;

 

typedef union _WORD_VAL

{

WORD Val;

struct

{

BYTE LSB;

BYTE MSB;

} byte;

BYTE v[2];

} WORD_VAL;

 

typedef struct _APP_CONFIG

{

WORD_VAL SerialNumber;

BYTE Flags;

} APP_CONFIG;

 

#define bIsDHCPEnabled 0b00000001

 

void DoTest(void);

 

----- test1.c -----

#include "test1.h"

 

APP_CONFIG AppConfig;

 

void main(void)

{

DoTest();

}

 

 

----- test2.c -----

#include "test1.h"

 

extern APP_CONFIG AppConfig;

 

 

void DoTest(void)

{

if ( AppConfig.Flags & bIsDHCPEnabled )

{

AppConfig.SerialNumber.Val = 0;

}

}

 

Playing with the struct showed:

- If SerialNumber is defined as WORD instead of WORD_VAL, and the .Val reference in test2. removed, the problem goes away.

- If the struct { } byte; part of the WORD_VAL struct is removed the problem goes away.

- Changing the names of elements of struct {} byte, eg LSB to lsbyte and byte to s_byte did not remove the problem.

 

 

 

My workaround will be to remove the inner struct {} byte and change code to use the v array.

 

I'm using :

 

IDE version: 6.70

Compiler: BoostC for PIC18

Compiler version: 6.70

Target device: PIC18F25J10

OS: Windows XP SP2

 

As an aside, are there any tools available for inspecting BoostC object files? It would have been helpful when tracking this down to be able to see which of the object files had a type for AppConfig that was different to the others; and interesting to see what was different!

 

Cheers

 

John

Share this post


Link to post
Share on other sites

i feel sorry for you, the Microchip TCP/IP Stack/Webserver is the worst example

of programming i have ever come accross using C.

 

Personally i have tried ~ 10 times to strip it down to its core elements, but the

code is so convoluted it is almost impossible. That was while using the MCC18

compiler, i imagine it is a nightmare to port to BoostC.

 

Unfortunatly for me, i have to try it again soon or write a custom library for one

of my own projects. If you do manage to get yours to compile atleast, i would

be interested in seeing your changes.

 

Btw WORD is defined in one (or many more! ) of the files somewhere, i discovered

that while trying to strip it down.

Edited by emte

Share this post


Link to post
Share on other sites
i feel sorry for you, the Microchip TCP/IP Stack/Webserver is the worst example

of programming i have ever come accross using C.

 

....

Unfortunatly for me, i have to try it again soon or write a custom library for one

of my own projects. If you do manage to get yours to compile atleast, i would

be interested in seeing your changes.

 

....

 

 

I think I've seen worse :( And I think I'm getting an understanding of the way the programmer thinks, and it is making sense to me now. I agree it could have been constructed more neatly.

 

I'm making good progress, got DHCP and ARP working, now debugging ICMP ping before I move onto TCP sockets. My biggest worry is that once it is all working there will not be enough code space left for the application I have in mind. And I really could have done without compiler bugs (I've since found another that I'll report shortly), but SourceBoost is doing the job.

 

I am planning on releasing the modified code once I have it under control, but I'm not sure what forum it should go to - any suggestions?

 

Cheers

 

John

Share this post


Link to post
Share on other sites

John,

I am planning on releasing the modified code once I have it under control, but I'm not sure what forum it should go to - any suggestions?

Sounds like a good piece of work. There is however a problem with publishing the code as it has Microchips copyright.

 

Regards

Dave

Share this post


Link to post
Share on other sites

John,

I've been trying to compile the Microchip TCP/IP stack for an Olimex PIC_MINI_WEB device, and after many syntax alterations to suit BoostC all the source files compile OK but I struck this error at link time:

 

 

failure

Error:Linking externs failed, mismatch of data types for variable:'AppConfig'

This has been fixed and will be in the next release.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Could it be posted as a set of diffs?

 

Since the diffs are your own IP, (perhaps) it would not count as an infringement.

 

Also, perhaps the changes could be posted through uChips forums.

 

John,
I am planning on releasing the modified code once I have it under control, but I'm not sure what forum it should go to - any suggestions?

Sounds like a good piece of work. There is however a problem with publishing the code as it has Microchips copyright.

 

Regards

Dave

Share this post


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...
Sign in to follow this  

×
×
  • Create New...