Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] IAR compilation failure, CCS compilation works. Types Incompatibility

Status
Not open for further replies.

yolco

Member level 2
Member level 2
Joined
Jun 12, 2009
Messages
48
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,286
Activity points
1,787
After developing a new firmware (main and libraries) with CCS for my CC2538, all errors are debugged, and now, device is working fine.

As from CCS I can not flash the firmware permanently, I'm working with IAR to develop this action.

On IAR, I have created the workspace, the project and included all libraries and files needed to compile the firmware. But, compilation fails due to incompatible types errors.

  • Error[Pe144]: a value of type "int" cannot be used to initialize an entity of type "signed short *"
int16_t *accData[3] = malloc(sizeof(int16_t));

  • Error[Pe513]: a value of type "int" cannot be assigned to an entity of type "signed short *"
int16_t *accData[3] = malloc(sizeof(int16_t));

  • Error[Pe120]: return value type ("signed short **") does not match the function type ("signed short*")
int16_t * lsm303d_readAccData(void)
{
int16_t *accData[3] = malloc(sizeof(int16_t));
...
return accData;​
}

Which is the root cause of these errors?
Maybe, any option of the compiler? Do I need to add any file? Or prototype on the code?

KR!

- - - Updated - - -

At second error the code is wrong. I missmatch at copy time.
Please find here the code for Pe513:
uint8_t xlo;
...
accData[i++] = (xlo | (xhi << 8));
 

None of the three code lines seems to show valid C code. The error messages are well understandable, the curious point is how CCS C could accept the code. Perhaps a code example that compiles in CCS C can clarify this.
 

Maybe I was a bit confusing at description. The code compiles well at CCS, the problem is at IAR.
Although I share your opinion about how CCS is accepting that code is incomprenhensible.

I have fixed the errors changing the way I reserve allocated memory with malloc.

  • Original code:
int16_t *accData[3] = malloc(sizeof(int16_t));
  • Modified code:
int16_t *accData = malloc(sizeof(int16_t) * 3);

Now, IAR compiles well, I need to develop another actions, and then I will test it on target.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top