General discussion

Locked

compiler error in visual C++

By adel_ibrahim ·
#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <stdlib.h>

#define LPT1 0x00400008
#define LPT2 0x0040000a
#define LPT3 0x0040000c
#define LPT4 0x0040000e

int main(int argc, char *argv[])
{
unsigned int port,data;unsigned int *bios_printer_addr;

if (argc>3) exit(1);
switch(argc)
{
case 1:
exit(1);

case 2:
port=*(bios_printer_addr=LPT1);

if (port==NULL)
{
printf("LPT1 does not exist\n");
exit(1);
}
sscanf(argv[1],"%x",&data);
break;

case 3:
if (argv[1][0]=='/')

switch(argv[1][1])
{
case '1':
port=*(bios_printer_addr=LPT1);
if (port==NULL)
{
printf("LPT1 does not exist\n");
exit(1);
}
sscanf(argv[2],"%x",&data);
break;

case '2':
port=*(bios_printer_addr=LPT2);
if (port==NULL)
{
printf("LPT2 does not exist\n");
exit(1);
}
sscanf(argv[2],"%x",&data);
break;

case '3':
port=*(bios_printer_addr=LPT3);
if (port==NULL)
{
printf("LPT3 does not exist\n"); exit(1);
}
sscanf(argv[2],"%x",&data);
break;

case '4':
port=*(bios_printer_addr=LPT4);
if (port==NULL)
{
printf("LPT4 does not exist\n");
exit(1); }
sscanf(argv[2],"%x",&data);
break;

default:
printf("Invalid printer port!\n");
exit(1);
}

else exit(1);
}


int _outp(port,data);
return 0;
}

when I comile thiscod I got the error:
(C:\3074_dos\RELAY.C(92) : error C2143: syntax error: missing ';' before 'type').
This line contained this code(int _outp(port,data)

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

compiler error in visual C++

by jeng In reply to compiler error in visual ...

There is a space between "int" and "_outp" on the line. The compiler is trying to declare a variable "_outp" of type "int". Try removing the embedded space.

Collapse -

compiler error in visual C++

by adel_ibrahim In reply to compiler error in visual ...

Many Thanks For reply.
I removed the space between "int and "_outp" as you said and I got 0 error but I also got The follwing warning:
(warning C4013: 'int_outp' undefined; assuming extern returning int).
Please help me to remove this warning.
regards

Collapse -

compiler error in visual C++

by Lo In reply to compiler error in visual ...

You need to declare the routine type for "int_outp) like you did with "int main(...". The first answer may have been incorrect, "int _outp" was correct with the space. I think you need to define the argument type for port and data as done in "int main(int argc, char *argv[])".

Or if "_outp" is an existing C routine shouldn't "int _outp(port,data)" be "_outp(port, data)"?

If you are creating, syntax is incorrect, port and data need datatype as was done for "main(...", "int _outp(int port, int data)", also the "{" and "}" are mismatched if you are creating.

Collapse -

compiler error in visual C++

by adel_ibrahim In reply to compiler error in visual ...

Poster rated this answer

Collapse -

compiler error in visual C++

by adel_ibrahim In reply to compiler error in visual ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums