error at compiling

M

Martin Petzold

Hello,

i have got a small problem while compiling my helloworld.c where i
include a driver class (comm.c). i compile under winXP with minGW and
have got this error:

--------------------------------------------------------------
D:\develop\spiderbot\testing>gcc hello.c
In file included from hello.c:4:
comm.c:45: parse error before "far"
comm.c:47: parse error before "far"
comm.c:47: warning: data definition has no type or storage class
comm.c:52: parse error before "far"
---------------------------------------------------------------

code snip (starting at line 45):
---------------------------------------------------------------
void (interrupt far *Serial)(); /* for origninal serial int. */

void interrupt far Handler(void);

/****************************************/
/* The actual serial interface driver */
/****************************************/
void interrupt far Handler(void)
----------------------------------------------------------------

can someone help me?

i have took out "#include <alloc.h>" at the beginning of comm.c because
this also made an error (couldent find taht file)...

thx for help!
martin petzold
 
B

Ben Pfaff

Martin Petzold said:
void (interrupt far *Serial)(); /* for origninal serial int. */

Neither `interrupt' nor `far' is a keyword in C. It looks like
you are trying to compile old, nonstandard MS-DOS code on another
platform. It would probably be easier to rewrite it from scratch
than to port it.
 
E

Eric Sosman

Martin said:
Hello,

i have got a small problem while compiling my helloworld.c where i
include a driver class (comm.c). i compile under winXP with minGW and
have got this error:

--------------------------------------------------------------
D:\develop\spiderbot\testing>gcc hello.c
In file included from hello.c:4:
comm.c:45: parse error before "far"
comm.c:47: parse error before "far"
comm.c:47: warning: data definition has no type or storage class
comm.c:52: parse error before "far"

`far' is not a keyword in the C language. In fact, it's
in the class of names specifically reserved for use as user-
defined identifiers: variable names, function names, struct
tags, and so on. So a C compiler reads this declaration in
exactly the same way it would read

void (interrupt widgets_per_wombat *Serial)();

.... and of course that makes no sense.

Compilers for some non-Standard C-ish variants use `far'
as a keyword to handle peculiarities of their underlying
platforms. If you need to use `far' in your code, you'll
need (1) to find such a non-C compiler and platform, and
(2) to seek advice from a newsgroup or other forum devoted
to that platform. In this case, it seems some kind of a
Microsoft newsgroup would be most helpful.
 
D

Default User

Martin said:
Hello,

i have got a small problem while compiling my helloworld.c where i
include a driver class (comm.c). i compile under winXP with minGW and
have got this error:
void (interrupt far *Serial)(); /* for origninal serial int. */


You are trying to use a nonstandard pointer declaration that was used on
some old MSDOS compilers. Get rid of all of them, the "far" declaration
is not necessary.



Brian Rodenborn
 
M

Martin Petzold

Hi,

Ben said:
Neither `interrupt' nor `far' is a keyword in C. It looks like
you are trying to compile old, nonstandard MS-DOS code on another
platform. It would probably be easier to rewrite it from scratch
than to port it.

thx! that was it...im not good at c jet. I have now got the win32 class
for this module an got this error:

D:\develop\spiderbot\testing>gcc hello.cpp
In file included from svlib.cpp:16,
from hello.cpp:2:
svlib.h:18: redefinition of `class SV200'
svlib.h:18: previous definition of `class SV200'

code
-------------------------------------------------------------------
#define SERVO1 1
#define SERVO2 2
#define SERVO3 3
#define SERVO4 4
#define SERVO5 5
#define SERVO6 6
#define SERVO7 7
#define SERVO8 8

#define NC -1

class CComm;

class SV200
{
protected:
CComm *comm;

char numStr[10];
int svSelect;
int savePosition[8];

void SerlXmitStr(char *str);

public:
SV200();
SV200(int comPort, int baudRate = 9600);
~SV200();
int Close(void);

void SvCmmd(char *cmmd, int param);
void SvCmmd2(char *cmmd, int param1, int param2);
void SelectBoard(int board);
void SelectServo(int servo);
void MoveSelect(int position);
void Move(int servo, int position);
void MoveAll(int S1, int S2, int S3, int S4, int S5, int S6, int
S7, int S8);
int GetNum(void);
unsigned char GetAD(int channel);
int AdjADJoystick(int position);

};
 
M

Martin Petzold

Martin said:
Hi,

Ben said:
Neither `interrupt' nor `far' is a keyword in C. It looks like
you are trying to compile old, nonstandard MS-DOS code on another
platform. It would probably be easier to rewrite it from scratch
than to port it.


thx! that was it...im not good at c jet. I have now got the win32 class
for this module an got this error:

D:\develop\spiderbot\testing>gcc hello.cpp
In file included from svlib.cpp:16,
from hello.cpp:2:
svlib.h:18: redefinition of `class SV200'
svlib.h:18: previous definition of `class SV200'

code
-------------------------------------------------------------------
#define SERVO1 1
#define SERVO2 2
#define SERVO3 3
#define SERVO4 4
#define SERVO5 5
#define SERVO6 6
#define SERVO7 7
#define SERVO8 8

#define NC -1

class CComm;

class SV200
{
protected:
CComm *comm;

char numStr[10];
int svSelect;
int savePosition[8];

void SerlXmitStr(char *str);

public:
SV200();
SV200(int comPort, int baudRate = 9600);
~SV200();
int Close(void);

void SvCmmd(char *cmmd, int param);
void SvCmmd2(char *cmmd, int param1, int param2);
void SelectBoard(int board);
void SelectServo(int servo);
void MoveSelect(int position);
void Move(int servo, int position);
void MoveAll(int S1, int S2, int S3, int S4, int S5, int S6, int S7,
int S8);
int GetNum(void);
unsigned char GetAD(int channel);
int AdjADJoystick(int position);

};
------------------------------------------------------------------

just would like to have it running once and then try (and learn) more...

thx martin

okay! i found that on my own!
thx for all!
 
K

Keith Thompson

Martin Petzold said:
D:\develop\spiderbot\testing>gcc hello.cpp
In file included from svlib.cpp:16,
from hello.cpp:2:
svlib.h:18: redefinition of `class SV200'
svlib.h:18: previous definition of `class SV200'

code [...]
class CComm;
[...]

That's C++, not C, so we can't help you with it here. Try posting
your question in comp.lang.c++.

(When you do, make sure you post the complete program that you tried
to compile, preferably narrowed down to a small program that exhibits
the problem. The error message refers to files being included but
there's no "#include" in the source you posted.)
 
M

Martin Ambuhl

Martin said:
Hello,

i have got a small problem while compiling my helloworld.c where i
include a driver class (comm.c). i compile under winXP with minGW and
have got this error:

--------------------------------------------------------------
D:\develop\spiderbot\testing>gcc hello.c
In file included from hello.c:4:
comm.c:45: parse error before "far"
comm.c:47: parse error before "far"
comm.c:47: warning: data definition has no type or storage class
comm.c:52: parse error before "far"

Neither "interrupt" nor "far" have any meaning in C apart from what you
define them to be. Apparently you use some implementation where these are
given a meaning. It is a very poor idea to ask questions about
implementation-specific invasions of your namespace here. Surely there is
a newsgroup, mailing list, or tech supprt for your implementation where you
could ask.
 
D

Darrell Grainger

Hello,

i have got a small problem while compiling my helloworld.c where i
include a driver class (comm.c). i compile under winXP with minGW and
have got this error:

--------------------------------------------------------------
D:\develop\spiderbot\testing>gcc hello.c
In file included from hello.c:4:
comm.c:45: parse error before "far"
comm.c:47: parse error before "far"
comm.c:47: warning: data definition has no type or storage class
comm.c:52: parse error before "far"

Neither the word 'interrupt' or 'far' are part of the C standard. Some
compilers extend the list of keywords. If this is the case then this
source code will only compile on a specific compiler.

Another option is that there is a header with typedefs. You could try
scanning your headers for the content 'interrupt' and 'far'. #include the
appropriate header if you find it.

If all else fails try asking in a newsgroup specific to your operating
system or compiler.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top