Topic : A compiler problem with typedef struct.

Forum : ST7/STM8

Original Post
Post Information Post
February 2, 2012 - 9:08pm
Guest

Hi,
I'm new to STM8 development and right on the deginning i have bumped into a showstopper problem.

Perhaps this is an simple mistake on my side but i cannot get the compliler to compile this header file:

/*rfm12 driver*/
#ifndef __RFM12_DRV_H
#define __RFM12_DRV_H

/* Includes ------------------------------------------------------------------*/
#include "stm8l10x.h"

#define MAX_TRANSMIT_BUFFER_LENGTH (32)
#define MAX_RECEIVE_BUFFER_LENGTH  (32)

typedef struct {
    uint8_t length;
    uint8_t data[MAX_TRANSMIT_BUFFER_LENGTH];
} t_transmit_buffer;

typedef struct {
    uint8_t length;
    uint8_t data[MAX_RECEIVE_BUFFER_LENGTH];
} t_receive_buffer;

void rfm12_init(void);
void rfm12_transmit(transmit_buffer* trans_data);
void rfm12_receive(receive_buffer* rec data);

#endif /*__RFM12_DRV_H*/

It looks fine to me, but i keep on gettting this set of errors:

*** ERROR C000 IN LINE 13 OF ..\..\/rfm12_drv.h : Character '}' missing

*** ERROR C000 IN LINE 11 OF ..\..\/rfm12_drv.h : Character '}' missing

*** ERROR C131 IN LINE 13 OF ..\..\/rfm12_drv.h : unbalanced #if-endif controls

What may be the reason for theese errors?
Thanks,
Pawel

Replies
Post Information Post
+1
0
-1
February 3, 2012 - 9:02am
Raisonance Support Team

Hi Pawel,

You have this problem because you use the uint8_t type, which is not defined.
You must ensure (perhaps in your stm8l10x.h file) that it is properly defined, for example :

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned long uint32_t;

Best Regards,

+1
0
-1
February 3, 2012 - 3:36pm
Guest

Hi Bruno,
Thanks for your answer. I have double checked the typedefs. They are included in the stm8l10x.h. Can you think of any other reason for this error?

BR,
Pawel

+1
0
-1
February 6, 2012 - 8:59am
Raisonance Support Team

Hi Pawel,

I missed this one : You are using "data" as a struct member name. However, it is a reszerved keyword on RCSTM8 (indicates that a variable should be located in a 16-bit space).

=> Change "data" to "_data" (or anything else) and it should be ok.

Best Regards,

+1
0
-1
February 8, 2012 - 9:49am
Guest

Thanks Bruno,
I will check that.