Discussion Locked

compiler error in visual C++

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

#include
#include
#include
#include

#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);)

5 replies

by jeng

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.

by adel_ibrahim

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

by lo

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.

This discussion is closed to new replies.