user-0 提问: error C2143: 语法错误 : 缺少“｛”(在“类型”的前面)

回复:
user: user-1
content: 引用 楼主 eknas111 的回复:编译头文件的时候 总是报错 第21行  #ifndef UTIL_H #define UTIL_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <math.h> #include <time.h> #include "param.h" #define BLOCK_WIDTH 16 #define BLOCK_HEIGHT 16 #define MAX_INT 255*BLOCK_WIDTH*BLOCK_HEIGHT+1 #define ODD 0 #define EVEN 1 #define max(a,b) (((a)>(b))?(a):(b)) #define min(a,b) (((a)<(b))?(a):(b)) #define swap(a,b,tmp) ((tmp)=(a),(a)=(b),(b)=(tmp)) #define abs(x) ((x) <0 ? -(x) : (x)) #define cint(x) ((x)+(x)%2) #define MAX_DISP 7 typedef u_char **BLOCK; typedef struct {    char   x;    char   y; } MV; typedef struct {    MV     mv;    char   f; } MVF; typedef struct {    MV   mv;    int   mae; } ME; #ifdef OPC typedef struct {    double a;    double p;    double c; } OP; extern   OP   op; extern double ls; extern double op_m; int merr_update; #endif const double mult_p[16],mult_ls[16];  //For UCBDS, HEX, CDS, a more precise in counting the no. of search point. int searchedpt[MAX_DISP*2+1][MAX_DISP*2+1];  //For method 33, FS with different number of pels in the SAD. extern int no_of_pel; int pel_loc[16][16];  extern   int   im_width, im_height, mv_width, mv_height; extern   int   im_width2, im_height2, mv_width, mv_height; extern   int   re_width,re_height,re_width2,re_height2; extern const u_char KK[16], LL[16]; void pgm_header(char *name, int width, int height); void g_alloc(u_char ***buf, int width, int height, int size); u_char *block_alloc(int width, int height); void block_free(void **buf); MV **mv_alloc(int width, int height); MVF **mvf_alloc(int width, int height); ME **me_alloc(int width, int height); void readframe(FILE *fp, u_char *frame, int width, int height); void res_image(u_char *ref, u_char *res, MV **mv); void hres_image(u_char *ref, u_char *res, MV **imv, MV **hmv); void fres_image(u_char *ref, u_char *res, MVF **mvt, MVF **mvb); void writeframe(FILE *fp, u_char *frame, int width, int height); int gradx(u_char *a_block, int x, int y, int width); int grady(u_char *a_block, int x, int y, int width); int mean_abs_err(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height); int num_of_pels4mean_abs_err(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height, int numpel); int half_stop_mean_abs_err(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height, int merr); int liu_abs_err(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height, int px, int py); int npd_mean_abs_err(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height, int merr); void merr_p_update(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height, int merr); int pdcf(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height); int smean_abs_err1(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height, int space); int smean_abs_err2(u_char *a_block, u_char *b_block, int x, int y, int m, int n, int width, int height, int space); double mean_squ_err(u_char *a_block, u_char *b_block, int width, int height); int abs_var(u_char *block, int x, int y, int h_length); void sub_block(BLOCK a_block, BLOCK s_block, int x, int y, int height); void interpolate_frame(u_char *ipol_image, u_char *image, int width, int height); void mult1_16(int x, int d, int *p); void gen_mult(int x, int d, int *p); BLOCK sub_alloc(int height); void sort_me(ME *buf, int no, int to); void insert_me(ME **buf, int no); void bi_insert_me(ME **buf, int no); char med(char a, char b, char c); void alloc_fail(void); void fopen_err(void); void init_searchedpt(void); int count_searchedpt(void); void print_searchedpt(void); #endif 神马编译给你报错,运行时段错误这种,自己仔细老老实实的找,这是基本功,只要你想从事这行怎么也跑不掉

user: user-2
content: 你定义的BLOCK为一个二级指针类型，那么看你的使用该类型时是否是类型匹配的。你的排版太密集，没有详看。

user: user-3
content: typedef是为现有类型创建一个新的名字，typedef u_char **BLOCK这句话显然不对， 应该是typedef 类型名 新类型名,你是要 typedef unsigned char **BLOCK吗？

user: user-4
content: 实在没有耐力把你的那段代码看完，太费劲！

user: user-5
content: 括号没有配对呗，好好检查一下

user: user-0
content: util.h(21): error C2143: 语法错误 : 缺少“{”(在“*”的前面)

user: user-5
content: 详细的错误信息，光这一句....让大家猜迷啊...

user: user-0
content: 第21行是 typedef u_char **BLOCK;

user: user-5
content: 鬼知道你的21行在哪