使用IAR编译器为RL78进行Vectorcast

时间:2017-09-25 08:07:51

标签: c embedded

我刚刚开始使用Vectorcast和IAR for RL78编译器。我想使用IAR Compiler for RL78 Microcontroller在vectorcast中构建一个环境。

用于测试的代码已成功编译在RL78的IAR嵌入式工作台中。

我在模拟的vectorcast中构建环境时遇到以下错误。

错误:

40_MCAL\Memory\FDL\fdl_types.h", line 133: error:
          division by zero
  enum { R_FDLT02_ASSERT_LINE_133 = 1/(! !(sizeof(fdl_u16)==2)) };
                                     ^

40_MCAL\Memory\FDL\fdl_types.h", line 137: error:
          division by zero
  enum { R_FDLT02_ASSERT_LINE_137 = 1/(! !(sizeof(fdl_command_t)==1)) };
                                     ^

40_MCAL\Memory\FDL\fdl_types.h", line 138: error:
          division by zero
  enum { R_FDLT02_ASSERT_LINE_138 = 1/(! !(sizeof(fdl_status_t)==1)) };
                                     ^
40_MCAL\Memory\FDL\fdl_types.h", line 141: error:
          division by zero
  enum { R_FDLT02_ASSERT_LINE_141 = 1/(! !(sizeof(fdl_request_t)==8)) };
                                     ^


40_MCAL\Memory\FDL\fdl_types.h", line 142: error:
          division by zero
  enum { R_FDLT02_ASSERT_LINE_142 = 1/(! !(sizeof(fdl_descriptor_t)==10)) };
                                     ^   
5 errors detected in the compilation of "Flash.c".

源代码如下:

# define R_FDLT02_ASSERT_CONCAT_(a, b) a##b        

#define R_FDLT02_ASSERT_CONCAT(a, b) R_FDLT02_ASSERT_CONCAT_(a, b)    

#define R_FDLT02_STATIC_ASSERT(e) enum { R_FDLT02_ASSERT_CONCAT    
(R_FDLT02_ASSERT_LINE_, __LINE__) = 1/(!!(e)) }    

/* assertion if unsigned data type size is not correct, please evaluate compiler settings for integer types */

R_FDLT02_STATIC_ASSERT(sizeof(fdl_u08)==1);    

R_FDLT02_STATIC_ASSERT(sizeof(fdl_u16)==2);    

R_FDLT02_STATIC_ASSERT(sizeof(fdl_u32)==4);    


/* assertion if enumeration type size is not correct, please evaluate compiler settings for enumeration types */    

R_FDLT02_STATIC_ASSERT(sizeof(fdl_command_t)==1);    

R_FDLT02_STATIC_ASSERT(sizeof(fdl_status_t)==1);    

/* assertion if structure type size is not correct, please evaluate compiler settings for structure types */    

R_FDLT02_STATIC_ASSERT(sizeof(fdl_request_t)==8);    

R_FDLT02_STATIC_ASSERT(sizeof(fdl_descriptor_t)==10);    

1 个答案:

答案 0 :(得分:0)

如果指定类型的大小不是库的要求,则它们是用于编译失败的表达式。

您需要检查fdl_u16等类型的定义是否适合您的目标。对于IAR的RL78编译器,基本类型具有以下大小:

bool               8 bits
char               8 bits 
signed char        8 bits
unsigned char      8 bits
signed short       16 bits
unsigned short     16 bits 
signed int         16 bits 
unsigned int       16 bits
signed long        32 bits 
unsigned long      32 bits
signed long long   32 bits
unsigned long long 32 bits 

它通常更具可移植性,但是如果需要特定大小来根据类型(例如uint16_t)定义此类型。

然而,考虑到fdl_u16fdl_u8没有错误,很难想到fdl_u32的合理定义,其大小不是2,但你有未提供该代码。

任何特定枚举的大小为1的明显期望是不安全的(例如,参见What is the size of an enum in C?),尽管在IAR RL78编译器手册中它指出将使用可容纳所有枚举常量的最小类型

结构类型的失败很可能是fdl_u16失败的结果,但是再次没有这些类型的定义很难说。