在'*'标记之前仍然存在“错误:预期”=',',',';','asm'或'__attribute__' [英] Still the "error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token"
问题描述
这是一个说明问题的小型纯C程序。该计划没有做任何事情;这是一个大型程序的简化版本,展示了同样的问题。
以下是这种情况:
Mac OS X Lion;
gcc版本i686-apple-darwin11-llvm-gcc-4.2(GCC)4.2.1(基于Apple Inc. build 5658)( LLVM build 2335.15.00);
示例代码:
#include
#include< stdio.h>
char巨大* pbA;
char巨大* pbB;
int main(int argc,char * argv [])
{
pbA =(char huge *)farmalloc(2);
pbB = pbA;
*(pbB ++)='A';
return(0);
编译命令:
gcc -c -Wall -O -g -pipe -D_SDL myTest.c
错误信息:
myTest.c:4:error:expected'=',',', '''','asm'或'__attribute__'在'*'标记之前
:
myTest.c:5:错误:expected'=',',',';','asm'或'__attribute__' *'令牌
myTest.c:在函数'main'中:
myTest.c:10:错误:'pbA'未声明(在此函数中首次使用)
myTest.c:10:错误:(每个未声明的标识符只报告一次
myTest.c:10:错误:对于它出现的每个函数。)
myTest.c:10:error:expected')'before'huge'
myTest.c:10:warning:隐式声明函数'farmalloc'
myTest.c:11:错误:'pbB'未声明(在此函数中首次使用)
$ c
$ b那么,我错过了什么?
解决方案I m不确定什么/哪里
巨大
是,但是编译器无法按照你提供的内容找到它。你可能错过了一个标题)。至于farmalloc
,它看起来在< alloc.h>
中。现在关于使用这些,在巨大当计算机拥有最大640K内存时,近似/远/巨大的关键字曾经被用作旧MSDOS
天的内存模型。
过去15年内建立的任何机器都没有这个限制,所以
除非你有真正的问题,你必须使用真正过时的硬件,
我不会花时间使用分段内存模型语法。
巨大
,可能 farmalloc
,似乎被今天的标准所不赞成(就像远vs近指针一样)。只需使用 char *
和 malloc
即可;没有奇怪的,旧的标题。
This is a small pure C program illustrative of the problem. 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;
gcc version i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 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 (i.e. you're missing a header probably). As for farmalloc
, that looks to be in <alloc.h>
. Now about using these, there is an answer on another site for 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). Using just char *
and malloc
should be all you need; no strange, old headers.
这篇关于在'*'标记之前仍然存在“错误:预期”=',',',';','asm'或'__attribute__'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!