错误:在’int’之前预期’=’,’,’,’;’,’asm’或’__attribute__’

在LINUX中编译C程序时,我得到了foll。 错误:

stream.h:1123: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int' stream.h:1124: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mblk_t' stream.h:1125: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'mblk_t' 

第1123,1124和1125行如下:

 __STREAMS_EXTERN int adjmsg(mblk_t *mp, register ssize_t length); __STREAMS_EXTERN mblk_t *allocb(size_t size, unsigned int priority); __STREAMS_EXTERN mblk_t *copyb(register mblk_t *mp); 

C程序包含一个头文件,而头文件又包含stream.h。任何想法如何解决这个问题?

你的代码的上下文并不是很清楚,但在我看来你正在使用OpenSSL库(或者你正在使用该源代码进行复制和粘贴)。

streams_fastcall宏在kmem.h头文件中定义。 你加入了吗? 如果您只是进行复制和粘贴,则只需在STREAMS_EXTERN定义之前添加以下行:

 #ifndef streams_fastcall #if defined __i386__ || defined __x86_64__ || defined __k8__ #define streams_fastcall __attribute__((__regparm__(3))) #else #define streams_fastcall #endif #endif 

注意streams_fastcall 听起来像Microsoft特定(但在Windows上广泛使用)调用名为__fastcall约定。 我猜他们使用了这个名字,因为它使用regparm属性指定一些参数应该使用寄存器而不是堆栈来传递,这就是__fastcall定义的(或者仅仅因为它更快!lol)

很明显, __STREAMS_EXTERN的定义方式很__STREAMS_EXTERN

如何定义__STREAMS_EXTERN

如果错误与任何遗漏无关; 或者代码中的类似语法错误,检查对openSSL包含的错误引用。

你的openSSL包含/ opt / openssl / include / openssl中的err.h和evp.h,你编译的指令是-I。 -L / opt / openssl / lib,-l crypto和-l dl

在.h文件中包含此内容会引发错误:#include(与err.h相同)。

只需用以下内容替换它:#include即可解决它。