2012-04-24 120 views
2

我想编译cygwin下的565 powerPC的matlab生成代码。 当我执行以下编译命令:C错误:预计`=',`,';',`asm'或`__attribute__'之前

@powerpc-eabi-gcc -gdwarf-2 -c -mno-sdata -DMODEL=testMacs -DRT -DNUMST=2 
-DTID01EQ=1 -DNCSTATES=0 -DRT_STATIC -DMT=0 -I. 
-IC:/Programs/MATLAB/R2007b/simulink/include 
-IC:/Programs/MATLAB/R2007b/extern/include -IC:/cygwin/gnu/powerpc/extern 
2/includes 
-IC:/Programs/MATLAB/R2007b/rtw/c/src 
-IC:/Programs/MATLAB/R2007b/rtw/c/libsrc 
-IC:/cygwin/powerpc-eabi/powerpc-eabi/sys-include 
-IC:/macs_565_R14/Driver 
-IC:/cygwin/ecos/include 
-mcpu=505 -O1 -o ./obj/testMacs.o testMacs.c 

我得到以下错误:

In file included from testMacs.h:16:0, 
       from testMacs.c:11: 
C:/cygwin/powerpc-eabi/powerpc-eabi/sys-include/math.h:12:1: error: expected `=', `,', `;', `asm' or `__attribute__' before `union' 
C:/cygwin/powerpc-eabi/powerpc-eabi/sys-include/math.h:398:17: error: expected `=', `,', `;', `asm' or `__attribute__' before `const' 
In file included from rtwtypes.h:12:0, 
       from testMacs.h:17, 
       from testMacs.c:11: 
C:/Programs/MATLAB/R2007b/extern/include/tmwtypes.h:83:1: error: expected `=', `,', `;', `asm' or `__attribute__' before `typedef' 

的文件math.h rtwtypes.h是标准不变的头文件。

有谁知道我做错了什么,或者我是否缺少编译器选项。

代码snippeds: testMacs.h:

/* 
* testMacs.h 
* 
* Real-Time Workshop code generation for Simulink model "testMacs.mdl". 
* 
* Model Version    : 1.6 
* Real-Time Workshop version : 7.0.1 (R2007b+) 21-Apr-2008 
* C source code generated on : Mon Apr 23 06:48:14 2012 
*/ 
#ifndef RTW_HEADER_testMacs_h_ 
#define RTW_HEADER_testMacs_h_ 
#ifndef testMacs_COMMON_INCLUDES_ 
# define testMacs_COMMON_INCLUDES_ 
#include <stddef.h> 
#include <string.h> 
#include <math.h>   /* line 16*/ 
#include "rtwtypes.h"  /* line 17*/ 
#include "simstruc.h" 
#include "fixedpoint.h" 
#include "rt_logging.h" 
#include "rt_nonfinite.h" 
#endif 

文件math.h:

/* math.h -- Definitions for the math floating point package. */ 

#ifndef _MATH_H_ 
#define _MATH_H_ 

#include <sys/reent.h> 
#include <machine/ieeefp.h> 
#include "_ansi.h" 

_BEGIN_STD_C 

union __dmath    /* line 12*/ 
{ 
    __ULong i[2]; 
    double d; 
}; 

... ...

/* Global control over fdlibm error handling. */ 

enum __fdlibm_version 
{ 
    __fdlibm_ieee = -1, 
    __fdlibm_svid, 
    __fdlibm_xopen, 
    __fdlibm_posix 
}; 

    #define _LIB_VERSION_TYPE enum __fdlibm_version 
    #define _LIB_VERSION __fdlib_version 

    extern __IMPORT _CONST _LIB_VERSION_TYPE _LIB_VERSION;  /*line 398*/ 

    #define _IEEE_ __fdlibm_ieee 
    #define _SVID_ __fdlibm_svid 
    #define _XOPEN_ __fdlibm_xopen 
    #define _POSIX_ __fdlibm_posix 

rtwtypes.h:

/* 
* File: rtwtypes.h 
* 
* Definitions required by Real-Time Workshop generated code. 
* 
* Real-Time Workshop version: 7.0.1 
* Generated on: 2012-04-23 06:48:15 
*/ 

#ifndef __RTWTYPES_H__ 
#define __RTWTYPES_H__ 
#include "tmwtypes.h"    /* line 12*/ 

/* This ID is used to detect inclusion of an incompatible rtwtypes.h */ 
#define RTWTYPES_ID_C08S16I32L32N32F1 
#include "simstruc_types.h" 
#ifndef POINTER_T 
# define POINTER_T 

tmwtypes.h:

/* 
*  The following define is used to emulate when all integer types are 
*  32-bits. This is the case for TI C30/C40 DSPs which are RTW targets. 
*/ 
#ifdef DSP32 
# define INT8_T int 
# define UINT8_T unsigned int 
# define INT16_T int 
# define UINT16_T unsigned int 
#endif 
             /* line 83*/ 
/* 
* The uchar_T, ushort_T and ulong_T types are needed for compilers which do 
* not allow defines to be specified, at the command line, with spaces in them. 
*/ 

typedef unsigned char uchar_T; 
typedef unsigned short ushort_T; 
typedef unsigned long ulong_T; 
+0

什么是'testMacs.c'?错误表明你在'#include's之前有一些东西不应该在那里。 – geekosaur 2012-04-24 07:08:33

+0

你确定这是'C:/ Programs/MATLAB/R2007b/extern/include/tmwtypes.h'的第83行 - 即你正在寻找正确的目录吗?在空行上抛出一个错误没有多大意义。 – 2012-04-24 07:19:15

回答

3

好像_BEGIN_STD_C没有被定义(以及可能其他一些宏)时math.h正在处理中。但是,(至少_BEGIN_STD_C)应由_ansi.h照顾。

尝试使用-M选项进行编译,以确保包含正确的头文件和/或使用-E进行编译,以便查看预处理器输出。其中一个应该指出这个问题。

+0

这帮助我分配我可以看到_asni.h文件包含在许多不同的来源。 – fengels 2012-04-24 09:36:25

相关问题