2014-09-29 65 views
-1

已經意識到了誰比我同樣的問題的人後,我仍然得到這個錯誤:重新定義不同的基本類型=>的typedef

錯誤C2371:「ST_ELLIPSE」:重新定義;不同的基本類型
參見'ST_ELLIPSE'的聲明
C2371:'ST_VECTEURS':重新定義;不同的基本類型
參見'ST_VECTEURS'的聲明
'ST_ROI':重新定義;不同的基本類型
參見'ST_ROI'的聲明
'ST_CONVERSION':重新定義;不同的基本類型
參見'ST_CONVERSION'聲明
'ST_PARA_VISU':重新定義;不同的基本類型
看到的宣言 'ST_PARA_VISU'

以下是文件:

#define MAX_VAL_VISU  245 
#define MAX_VAL_VISU_SUPP 128 
#define MAX_VAL_OVR_SUPP 116 

#define VISU_SIZE_X   672 
#define VISU_SIZE_Y   512 
#define DELTA_ZONE   5 

#define FLAG_RIEN   1 
#define FLAG_ZOOM   2 
#define FLAG_DEP   4 
#define FLAG_STAT   8 
#define FLAG_CONTRASTE  16 
#define FLAG_ZONE   32 
#define FLAG_OVR_WRITE  64 
#define FLAG_OVR_EFF  128 
#define FLAG_OVR_TEXTE  256 
#define FLAG_ROI   512 // V2.0 

// flag de suppression (& avec flag au dessus) 
#define FLAG2_RIEN   0 // 0 aucune autres fenetres 
#define FLAG2_ZOOM   0 
#define FLAG2_DEP   0 
#define FLAG2_STAT   FLAG_CONTRASTE 
#define FLAG2_CONTRASTE  (FLAG_STAT | FLAG_ZONE | FLAG_ROI) 
#define FLAG2_ZONE   FLAG_CONTRASTE 
#define FLAG2_OVR_WRITE  (FLAG_ROI | FLAG_CONTRASTE) 
#define FLAG2_OVR_EFF  (FLAG_ROI | FLAG_CONTRASTE) 
#define FLAG2_OVR_TEXTE  0 
#define FLAG2_ROI   FLAG_CONTRASTE 


#define TYPE_MODIF_ZONE_RIEN 0 // pas de modification 
#define TYPE_MODIF_ZONE_H  1 // definition de la ligne Haut 
#define TYPE_MODIF_ZONE_B  2 // definition de la ligne BAS 
#define TYPE_MODIF_ZONE_G  3 // definition de la ligne gauche 
#define TYPE_MODIF_ZONE_D  4 // definition de la ligne droite 
#define TYPE_MODIF_ZONE_P1  5 // definition du point haut/gauche 
#define TYPE_MODIF_ZONE_P2  6 // definition du point bas/droite 
#define TYPE_MODIF_ZONE_P3  7 // definition du point bas/gauche 
#define TYPE_MODIF_ZONE_P4  8 // definition du point haut/droite 

#define LUT_GRAY  0 
#define LUT_COLOR1  1 
#define LUT_COLOR2  2 
#define LUT_FICHIER  3 
#define LUT_SUPERPOSITION 4 

#define NB_COULEUR 10 

#define ROI_ZONE 0 
#define NB_ROI  10 

#define NB_UNITE 2 

// structure 
//*********** 
// V2.0 
// ROI 
typedef struct 
{ 
    // données de depart 
    double x1[NB_UNITE],y1[NB_UNITE],x2[NB_UNITE],y2[NB_UNITE],d2[NB_UNITE]; 
    // donnee calculées 
    double d1[NB_UNITE]; 
    double x11,y11,x22,y22; 
    // angle de rotation 
    double angle; 
    // origine 
    double ox,oy; 
    // position foyer 
    double fx1,fx2,fy1,fy2,dist; 
    // min max en X et en Y 
    int x_min,y_min,x_max,y_max; 
}ST_ELLIPSE; 
typedef struct 
{ 
    int nb; 
    double x[NB_UNITE][10],y[NB_UNITE][10]; 
}ST_VECTEURS; 

#define ROI_RECTANGLE 0 
#define CHAR_ROI_RECTANGLE "R" 
#define ROI_ELLIPSE  1 
#define CHAR_ROI_ELLIPSE "E" 
#define ROI_VECTEURS 2 
#define CHAR_ROI_VECTEURS "V" 

typedef struct{ 
    bool flag_def_zone; 
    int type_roi; 
    // rectangle 
    double x_zone[NB_UNITE],y_zone[NB_UNITE],dx_zone[NB_UNITE],dy_zone[NB_UNITE]; 
    // ellipse 
    ST_ELLIPSE ellipse; 
    // vecteurs 
    ST_VECTEURS vecteurs; 
}ST_ROI; 

// V2.0 
#define CONVERSION_ZONE 1 // indice dans ST_CONVERSION 
// parametres de conversion pixel ->mm 
typedef struct { 
    double x_pix,x_mm,y_pix,y_mm; 
    double coef_x; 
    double coef_y; 
    CString unite[2]; 
}ST_CONVERSION; 

// V2.0 
// parametres de la visu 
typedef struct{ 
    int x_zoom,y_zoom,m_zoom; // zoom 
    ST_ROI roi[NB_ROI]; // roi 
    int ind_conversion; 
    ST_CONVERSION coef_conversion[2]; // conversion pour stat pix->autre unité 
}ST_PARA_VISU;` 

會有人有什麼想法?

感謝您的幫助!

+0

看起來你忘記了你的[包括守衛](http://en.wikipedia.org/wiki/Include_guard) – 2014-09-29 12:54:29

+0

'#pragma once'是你的朋友。把他放在每個.h文件的頂部。 – Yann 2014-09-29 13:09:18

+0

在C++中,你不需要使用'typedef struct'。您可以通過它們的標記名稱引用它們:struct ST_ROI {...};' – 2014-09-29 13:53:20

回答

1

在每個h文件的頂部把#pragma once是這樣做,如果你不介意使用宏的方式,否則,「適當」的方式來做到這一點是

#ifndef AWESOME_H 
#define AWESOME_H 
class Awesome 
{ 
    //awesome.h contents 
}; 
#endif 
+0

嗯......這不是「使用宏」嗎? – 2017-11-15 17:35:23

相關問題