error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int'

这一生的挚爱 提交于 2019-12-10 20:29:13

问题


While compiling a C program in LINUX, I get the foll. error:

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'

Line 1123,1124 and 1125 are given below:

__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);

The C program includes a header file which in turn includes stream.h Any idea how this can be solved?


回答1:


It's not really clear the context of your code but it seems to me that you're using the OpenSSL library (or you're doing copy & paste from that source code).

The streams_fastcall macro is defined in the kmem.h header file. Did you include it? If you're just doing copy & paste you simply have to add this lines before your STREAMS_EXTERN definition:

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

Note: streams_fastcall sounds like the Microsoft Specific (but widely used on Windows) calling convention named __fastcall. I guess they used that name because it uses the regparm attribute to specify that some arguments should be passed using registers instead of the stack and this is what __fastcall defines (or simply because it's simply faster! lol)




回答2:


Its pretty clear that __STREAMS_EXTERN is defined in a way that is messing things up.

How is __STREAMS_EXTERN defined?




回答3:


In case the error is not related to any missing ; or similar syntax error in your code, check for a bad referencing to the openSSL includes.

With your openSSL includes err.h and evp.h in /opt/openssl/include/openssl and you compile directives being -I. -L /opt/openssl/lib, -l crypto and -l dl

having this include in your .h file provokes the error: #include (same with err.h).

Simply replace it with this include: #include to solve it.



来源:https://stackoverflow.com/questions/10499389/error-expected-asm-or-attribute-before-int

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!