简体   繁体   English

仍然是“错误:在'*'标记之前出现预期的'=',',',';','asm'或'__attribute__'”

[英]Still the “error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token”

This is a small pure C program illustrative of the problem. 这是一个小的纯C程序,说明了该问题。 The program doesn't do anything; 该程序不执行任何操作。 it's a stripped-down version of a larger program that exhibits the same problem. 这是一个大型程序的精简版本,它也存在相同的问题。

Here is the scenario: 这是场景:

Mac OS X Lion; Mac OS X Lion;

gcc version i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00); gcc版本i686-apple-darwin11-llvm-gcc-4.2(GCC)4.2.1(基于Apple Inc.版本5658)(LLVM版本2335.15.00);

Sample code: 样例代码:

#include <stdlib.h>
#include <stdio.h>

char huge *pbA;
char huge *pbB;

int main(int argc,char *argv[])
{
    pbA = (char huge *)farmalloc(2);
    pbB = pbA;
    *(pbB++) = 'A';
    return( 0 );
}

Compile command: 编译命令:

gcc -c -Wall -O -g -pipe  -D_SDL myTest.c

Errors messages: 错误消息:

myTest.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
myTest.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
myTest.c: In function ‘main’:
myTest.c:10: error: ‘pbA’ undeclared (first use in this function)
myTest.c:10: error: (Each undeclared identifier is reported only once
myTest.c:10: error: for each function it appears in.)
myTest.c:10: error: expected ‘)’ before ‘huge’
myTest.c:10: warning: implicit declaration of function ‘farmalloc’
myTest.c:11: error: ‘pbB’ undeclared (first use in this function)

So, what am I missing? 那么,我想念什么?

I'm not sure what/where huge is, but the compiler can't find it in what you've given it (ie you're missing a header probably). 我不确定什么是huge的,但编译器无法在给定的范围内找到它(即,可能缺少标头)。 As for farmalloc , that looks to be in <alloc.h> . 至于farmalloc ,它似乎在<alloc.h> Now about using these, there is an answer on another site for huge : 现在,有关使用这些,对一个答案其他网站huge

Keywords like near/far/huge were once used as memory models in the old MSDOS 
days when computers had a max of 640K memory.

Any machine built in the last 15 years does not have that restriction so 
unless you have a real issue where you have to use really obsolete hardware, 
I would not spend time with segmented memory model syntax.

huge , and probably farmalloc as well, seem to be deprecated by today's standards (just like far vs near pointers). huge ,而且很可能farmalloc为好,似乎是由今天的标准被弃用(就像远VS近指针)。 Using just char * and malloc should be all you need; 只需要使用char *malloc可以了; no strange, old headers. 没有奇怪的旧标题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:“ {”令牌|之前的预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token| 错误:在&#39;:&#39;标记前应有&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token 错误:在'{'令牌之前预期'=',',',';','asm'或'__attribute__' - error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token :1:错误:在&#39;{&#39;标记之前应为&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - :1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token 错误:在 '.' 之前应有 '='、','、';'、'asm' 或 '__attribute__' 令牌 - error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token 错误:在“*”标记之前应有“=”、“、”、“;”、“asm”或“__attribute__” - error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token 在&#39;&#39;之前预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39;。 代币 - expected '=', ',', ';', 'asm' or '__attribute__' before '.' token “在&#39;-&gt;&#39;标记之前的预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - "Expected '=', ',', ';', 'asm' or '__attribute__' before '->' token 在&#39;{&#39;令牌之前预期&#39;=&#39;,&#39;,&#39;,&#39;;&#39;,&#39;asm&#39;或&#39;__attribute__&#39; - expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token 错误:预期在“ void”之前出现“ =”,“,”,“;”,“ asm”或“ __attribute__” - error: expected '=', ',', ';', 'asm' or '__attribute__' before 'void'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM