re-compile error

D

developer

re-compile under dev -c++ bloodshed.

can u help ?


#include<dos.h>
#include<process.h>
#include<io.h>
#include<stdio.h>
#define STROBE 0x01
#define NOT_STB 0x00

void main()
{
char i,j;
unsigned int CTRL_PORT,STAR_PORT;
unsigned int far *DATA_PORT;
DATA_PORT=MK_FP(0x0000,0x0408);
STAR_PORT=*DATA_PORT+1;
CTRL_PORT=STAR_PORT+1;
outport(CTRL_PORT,0x00);
while(1)
{
outport(*DATA_PORT,0x00);
delay(2000);
outport(*DATA_PORT,0xff);
delay(2000);
outport(*DATA_PORT,0x00);
delay(2000);
j=0x80;
for(i=0;i<8;i++)
{
outport(*DATA_PORT,j);
j=j>>1;
delay(2000);
}
}
}


Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\Documents and Settings\farm\TEST.C" -o "C:\Documents and
Settings\farm\TEST.exe" -g3 -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:/Documents and Settings/farm/TEST.C:9: `main' must return `int'
C:/Documents and Settings/farm/TEST.C: In function `int main(...)':
C:/Documents and Settings/farm/TEST.C:12: parse error before `*'
token
C:/Documents and Settings/farm/TEST.C:13: `DATA_PORT' undeclared
(first use this function)
C:/Documents and Settings/farm/TEST.C:13: (Each undeclared
identifier is reported only once for each function it appears in.)
C:/Documents and Settings/farm/TEST.C:13: `MK_FP' undeclared (first
use this function)
C:/Documents and Settings/farm/TEST.C:16: `outport' undeclared
(first use this function)
C:/Documents and Settings/farm/TEST.C:20: `delay' undeclared (first
use this function)

C:/Documents and Settings/farm/TEST.C: At global scope:
C:/Documents and Settings/farm/TEST.C:33: stray '\32' in program

C:/Documents and Settings/farm/TEST.C:33:3: warning: no newline at end of
file

Execution terminated
 
J

Jens.Toerring

developer said:
re-compile under dev -c++ bloodshed.
can u help ?

Not really...
#include<dos.h>
#include<process.h>
#include<io.h>

All these three are non-standard header files, probably available
on DOS based machines. To find help about them you have to ask in
a different group that deals with Microsoft-specific extensions to
the C language.
#include<stdio.h>
#define STROBE 0x01
#define NOT_STB 0x00
void main()

main() must return an int.
{
char i,j;
unsigned int CTRL_PORT,STAR_PORT;
unsigned int far *DATA_PORT;

The 'far' isn't standard C - it's usually found in old DOS programs.
A normal C compiler won't know what to do with it and assume that
you want to define an unsigned int variable called 'far' and choke
on what follows. Again, you need to ask in a MS-group to get help
about that.
DATA_PORT=MK_FP(0x0000,0x0408);

Because of the problem with the previous line DATA_PORT isn't
defined. And obviously the compiler doesn't know what MK_FP()
is supposed to be. It's not a standard C function and it doesn't
seem to be defined in the non-standard headers you included above,
at least the compiler tells you it hasn't found it in there.
STAR_PORT=*DATA_PORT+1;
CTRL_PORT=STAR_PORT+1;
outport(CTRL_PORT,0x00);

outport() isn't a standard C function and doesn't seem to be declared
in the the non-standard headers.
while(1)
{
outport(*DATA_PORT,0x00);
delay(2000);

And again the same problem with the delay() function.
outport(*DATA_PORT,0xff);
delay(2000);
outport(*DATA_PORT,0x00);
delay(2000);
j=0x80;
for(i=0;i<8;i++)
{
outport(*DATA_PORT,j);
j=j>>1;
delay(2000);
}
}

You're missing a statement like "return 0;" here - since main() is
supposed to return an int you must do so.

The last character in a regular C program must be a line feed. The ^Z
stuff is an abomination from very old DOS programs where it was meant
to indicate the end of the file. Normal compilers will choke on it.

Most of your problems seem to be due to the use of non-standard (DOS)
extensions. So you better go to a group that deals with MS specific
stuff. It probably would make sense also there to explain on what kind
of system you want to compile and run that program - I suspect that
even a newer Windows system wouldn't let you run that even if you get
it to compile and link.
Regards, Jens
 
F

Flash Gordon

re-compile under dev -c++ bloodshed.

can u help ?

Well, you dealing with the obvious things the compiler is telling you
would have been a start.
#include<dos.h>
#include<process.h>
#include<io.h>

The above are non-standard headers and here we have no idea what they
contain.
#include<stdio.h>
#define STROBE 0x01
#define NOT_STB 0x00

void main()

As your compiler correctly tells you main returns an int so you should
declare it as such.

int main(void)

since you don't use the parameters.
{
char i,j;

Some indentation would be a good idea.
unsigned int CTRL_PORT,STAR_PORT;

Common convention is to use lower case for variable names and upper case
for macros.
unsigned int far *DATA_PORT;

What is the far of which you speak? It certainly is not a standard C
keyword.

<OT>
This suggests the code was written for an ancient DOS compiler, since
far was a completely non-standard extention that some DOS compilers used
to provide.
DATA_PORT=MK_FP(0x0000,0x0408);

What is the MK_FP of which you speak? It is not declared in your
program, so unless it comes from your non-standard headers it does not
exist. Since your compiler complains I would suggest it does not exist.
STAR_PORT=*DATA_PORT+1;
CTRL_PORT=STAR_PORT+1;
outport(CTRL_PORT,0x00);

Same applies here. As far as we can see outport does not exist just as
your compiler suggests.
while(1)
{
outport(*DATA_PORT,0x00);
delay(2000);
outport(*DATA_PORT,0xff);
delay(2000);
outport(*DATA_PORT,0x00);
delay(2000);
j=0x80;
for(i=0;i<8;i++)
{
outport(*DATA_PORT,j);
j=j>>1;

If j is an 8 bit signed char this is a problem.
delay(2000);
}
}
}

What strange character is that after the close brace?

C:/Documents and Settings/farm/TEST.C: At global scope:
C:/Documents and Settings/farm/TEST.C:33: stray '\32' in program

Looks like that is the screwy character at the end of the file. Delete
it.
C:/Documents and Settings/farm/TEST.C:33:3: warning: no newline at end
C:eek:f
file

The last line of the file needs a newline, so press return at the end of
it then save after dealing with the above.
Execution terminated

If this is your code I suggest throwing it away and reading up on the
extensions your implementation provides that might let you do what you
want. If this is someone elses code that you have to recompile and use
then you will have to find out what system they used and use that since
the important bits of it are completely non-standard.

Either way there is very little we can help you with here, you need
implementation specific help and we deal with standard C.
 
J

James McIninch

Simply rewrite the code in C, modifying the compiler-specific portions to
accomodate the new compiler.
 
J

jacob navia

developer said:
re-compile under dev -c++ bloodshed.

can u help ?


#include<dos.h>
#include<process.h>
#include<io.h>
#include<stdio.h>
#define STROBE 0x01
#define NOT_STB 0x00

void main()
{
char i,j;
unsigned int CTRL_PORT,STAR_PORT;
unsigned int far *DATA_PORT;
DATA_PORT=MK_FP(0x0000,0x0408);
STAR_PORT=*DATA_PORT+1;
CTRL_PORT=STAR_PORT+1;
outport(CTRL_PORT,0x00);
while(1)
{
outport(*DATA_PORT,0x00);
delay(2000);
outport(*DATA_PORT,0xff);
delay(2000);
outport(*DATA_PORT,0x00);
delay(2000);
j=0x80;
for(i=0;i<8;i++)
{
outport(*DATA_PORT,j);
j=j>>1;
delay(2000);
}
}
}


Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\Documents and Settings\farm\TEST.C" -o "C:\Documents and
Settings\farm\TEST.exe" -g3 -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
C:/Documents and Settings/farm/TEST.C:9: `main' must return `int'
C:/Documents and Settings/farm/TEST.C: In function `int main(...)':
C:/Documents and Settings/farm/TEST.C:12: parse error before `*'
token
C:/Documents and Settings/farm/TEST.C:13: `DATA_PORT' undeclared
(first use this function)
C:/Documents and Settings/farm/TEST.C:13: (Each undeclared
identifier is reported only once for each function it appears in.)
C:/Documents and Settings/farm/TEST.C:13: `MK_FP' undeclared (first
use this function)
C:/Documents and Settings/farm/TEST.C:16: `outport' undeclared
(first use this function)
C:/Documents and Settings/farm/TEST.C:20: `delay' undeclared (first
use this function)

C:/Documents and Settings/farm/TEST.C: At global scope:
C:/Documents and Settings/farm/TEST.C:33: stray '\32' in program

C:/Documents and Settings/farm/TEST.C:33:3: warning: no newline at end of
file

Execution terminated

You are running under the windows OS. This OS is NOT the DOS
operating system that was discontinued more than 10 years ago.

This program is writing to a specific address. This will never work
under the win32 versions of windows (windows 95 or higher).

But all this is probably too technical for you. The fact that you
attempt to compile this under windows shows that you haven't got
any idea what this code is doing. I would suggest that you find
someone competent and give this to him (her).

Under DOS, you could write to any memory address since the OS
wasn't using protected mode and virtual memory. This doesn't work
since windows 95...

Anyway, maybe it will run if you compile it under a 16 bit DOS compiler
under the emulation layer of windows, who knows.

jacob
 
D

developer

if I can find turbo for win xp ( 32 bit) and recompile the program, will
that works?
can a 16 bit turbo C works on 32 bit machine?

or

if I can find a dos 3.3, and a copy turbo C compile and compile the edited
under dos 3.3?

what other option, to make this hardware and source code C that I have at
the moment, to make it work under XP environment.
 
J

jacob navia

developer said:
ttings\farm\TEST.exe" -g3 -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"

if I can find turbo for win xp ( 32 bit) and recompile the program, will
that works?

no, the 32 bit compiler will not work

can a 16 bit turbo C works on 32 bit machine?

under the emulation layer yes
or

if I can find a dos 3.3, and a copy turbo C compile and compile the edited
under dos 3.3?

yes. Get an old pC, install DOS, install turbo c 16 bits for DOS
recompile
what other option, to make this hardware and source code C that I have at
the moment, to make it work under XP environment.

Maybe it will work under the emulation layer, maybe not.

You will have to tweak the DOS emulation layer settings in the
properties of the shortcut to the program
 
J

Jens.Toerring

<lots of irrelevant stuff snipped>

Please remove things not relevant to your postings.
if I can find turbo for win xp ( 32 bit) and recompile the program, will
that works?
can a 16 bit turbo C works on 32 bit machine?
or
if I can find a dos 3.3, and a copy turbo C compile and compile the edited
under dos 3.3?
what other option, to make this hardware and source code C that I have at
the moment, to make it work under XP environment.

Ask these questions in a appropriate newsgroup. All this has nothing
to do with the programming language C and several people already told
you to go to a MS related newsgroup because that's where it might be
on-topic and where you will find the experts for that kind of prolems.

Regards, Jens
 
F

Flash Gordon

developer wrote:

<snip DOS/Windows specific rubish.
Maybe it will work under the emulation layer, maybe not.

You will have to tweak the DOS emulation layer settings in the
properties of the shortcut to the program

You will also have to take it to either a DOS/Windows news group or to
email. This is COMPLETELY OFF TOPIC.
 
M

Martin Ambuhl

developer said:
re-compile under dev -c++ bloodshed.
[...]
Please post implementation-specific questions to implementation-specific
newsgroups or mailing lists.

<off-topic>
I have no idea if this works (since the functions outportb and delay are
not part of C). The attempt to set DATA_PORT to a specific place in
memory is likely to fail; use your implementation-supplied mechanism for
that. Even in non-standard code like this, it would be a good idea to
stop flouting normal conventions with your use of all caps for things
that are not macros.

#include <pc.h> /* non-standard header */
#include <dos.h> /* non-standard header */

int main()
{
unsigned char i, j;
unsigned int CTRL_PORT, STAR_PORT;
unsigned int *DATA_PORT = (unsigned int *) 0x0408;
STAR_PORT = *DATA_PORT + 1;
CTRL_PORT = STAR_PORT + 1;
outportb(CTRL_PORT, 0x00);
while (1) {
outportb(*DATA_PORT, 0x00);
delay(2000);
outportb(*DATA_PORT, 0xff);
delay(2000);
outportb(*DATA_PORT, 0x00);
delay(2000);
j = 0x80;
for (i = 0; i < 8; i++) {
outportb(*DATA_PORT, j);
j = j >> 1;
delay(2000);
}
}
return 0;
}

</offtopic>
 
K

Keith Thompson

The last character in a regular C program must be a line feed. The ^Z
stuff is an abomination from very old DOS programs where it was meant
to indicate the end of the file. Normal compilers will choke on it.

A C source file must end in an end-of-line indicator, which is
translated to a new-line character in translation phase 1. This
needn't be a line feed character.

It's also possible that phase 1 will eliminate the ^Z character.
I have no idea whether the OP's compiler actually does this.
 
K

Keith Thompson

Keith Thompson said:
A C source file must end in an end-of-line indicator, which is
translated to a new-line character in translation phase 1. This
needn't be a line feed character.

It's also possible that phase 1 will eliminate the ^Z character.
I have no idea whether the OP's compiler actually does this.

Actually, since the OP's compiler complained about it:

C:/Documents and Settings/farm/TEST.C:33: stray '\32' in program

apparently it doesn't eliminate the ^Z character. ('\32' is ASCII
character 26, also known as ^Z.) Presumably the compiler for which
the source file was intended behaved differently.
 
J

Jack Klein

You are running under the windows OS. This OS is NOT the DOS
operating system that was discontinued more than 10 years ago.

If I've told you once, I've told you LLONG_MAX times not to
exaggerate.

<OT>
MS-DOS 7.1, on which this program would work with the appropriate
compiler, headers, and libraries, was shipping as part of Windows 98
well into the year 2000 when Windows 98 was replaced by Windows
Millennium. Hardly "more than 10 years ago". Not even 5, in fact.
</OT>
 
J

jacob navia

Jack said:
If I've told you once, I've told you LLONG_MAX times not to
exaggerate.

<OT>
MS-DOS 7.1, on which this program would work with the appropriate
compiler, headers, and libraries, was shipping as part of Windows 98
well into the year 2000 when Windows 98 was replaced by Windows
Millennium. Hardly "more than 10 years ago". Not even 5, in fact.
</OT>

An emulation layer is available still TODAY.

Those are *emulations* of msdos under a virtual 16 bit machine running
under the windows OS. NOT native compiled applications.

I spoke about that emulation layer in my message.
 

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
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top