[英]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.