Jump to content

Recommended Posts

Is this a bug?

 

Bug description:

Return type of function taking pointer to structure as an argument can not be enum type. They compile oky but generate a linker error message.

 

Steps to reproduce:

Two files, one calling the function and the other the function. They compile okay but generate an error when linking.

 

First file, main.c

// File main.c
// BoostC Compiler options -v -W2 -t PIC18F4550
#include <system.h>

/* BoostC v6.40 bug.  If a function takes a -> struct as an argument,
  the return type cannot be a typedef - generally get missing extern
  when linking to get round this, use unsigned char types

#ifndef BOOLEAN_VALUES
 #define BOOLEAN_VALUES
 #define BOOLEAN unsigned char
 #define FAILURE 0
 #define SUCCESS 1
#endif   
*/

/* !!!! When BoostC is sorted we can use the following
*/

#ifndef BOOLEAN_VALUES
 #define BOOLEAN_VALUES
 typedef enum { FAILURE=0, SUCCESS=1 } BOOLEAN;
#endif


struct _str
{
  char Char;
  int  Int;
};

extern BOOLEAN DoSomething(struct _str * p);

struct _str MyStructure;
BOOLEAN bRes;

void main()
{
 bRes=DoSomething(&MyStructure);
}  
// end of main.c

 

Second file, function.c

// File function.c
// BoostC Compiler options -v -W2 -t PIC18F4550
#include <system.h>

typedef enum { FAILURE=0, SUCCESS=1 } BOOLEAN;

struct _str
{
  char Char;
  int  Int;
};

BOOLEAN DoSomething(struct _str * p);

BOOLEAN DoSomething(struct _str * p)
{
 p->Char='A';
 p->Int = 65;
 return SUCCESS;
}

// end of function.c

 

Build output:

Building...
BoostC Optimizing C Compiler Version 6.40 (for PIC18 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2006 Pavel Baranov
Copyright(C) 2004-2006 David Hobday

Licensed to ... under Single user Full License for 1 node(s)
Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only


main.c
Starting preprocessor: "I:\Program Files\SourceBoost\pp.exe" "I:\BoostC Compiler\main.c" -i "I:\Program Files\SourceBoost\include" -d _PIC18F4550 -la -c2 -o main.pp -v -d _BOOSTC -d _PIC18 

main.c success

success
BoostC Optimizing C Compiler Version 6.40 (for PIC18 architecture)
http://www.sourceboost.com
Copyright(C) 2004-2006 Pavel Baranov
Copyright(C) 2004-2006 David Hobday

Licensed to ... under Single user Full License for 1 node(s)
Limitations: PIC18 max code size:Unlimited, max RAM banks:Unlimited, Non commercial use only


Function.c
Starting preprocessor: "I:\Program Files\SourceBoost\pp.exe" "I:\BoostC Compiler\Function.c" -i "I:\Program Files\SourceBoost\include" -d _PIC18F4550 -la -c2 -o Function.pp -v -d _BOOSTC -d _PIC18 

Function.c success

success
BoostLink Optimizing Linker Version 6.40
http://www.sourceboost.com
Copyright(C) 2004-2006 Pavel Baranov
Copyright(C) 2004-2006 David Hobday


Optimisation level:0 - Off
Error: function and prototype differ in return type:'DoSomething(struct _str*)'
Error: function and prototype differ in return type:'DoSomething(struct _str*)'
Internal Error:Unable to find function ID:0x10000390


Failure
"I:\Program Files\SourceBoost\boostc.pic18.exe" main.c -t PIC18F4550 -W2 -v -W2 -O0 
"I:\Program Files\SourceBoost\boostc.pic18.exe" Function.c -t PIC18F4550 -W2 -v -W2 -O0 
"I:\Program Files\SourceBoost\boostlink.pic.exe" /ld "I:\Program Files\SourceBoost\lib" libc.pic18.lib main.obj Function.obj /t PIC18F4550 /d "I:\BoostC Compiler" /p main -O0 
Exit code was -2.
Removing target: main.hex
Done

Expected behaviour:

Successful link.

 

Is the problem 100% reproduceable:

With this example, yes

 

IDE version: SourceBoost IDE version 6.40

Compiler: BoostC Compiler

Compiler version: 6.40

Target device: PIC18F4550

OS: : XP Pro SP2

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