visual studio compilling issues with solaris c code

M

merrittr

I get these errors when i try to compile some c code I am trying to
port to win32 . I would like to overide the built in shutdown() fn
and use the one in the code here. any ideas on how to get by this
( see full code below)


Error 11 error C2373: 'shutdown' : redefinition; different type
modifiers c:\projects\jmotion\jmotion\jmotion.c 30
Error 25 error C2198: 'shutdown' : too few arguments for call c:
\projects\jmotion\jmotion\jmotion.c 177
Error 35 error C2373: 'shutdown' : redefinition; different type
modifiers c:\projects\jmotion\jmotion\jmotion.c 459
























#include <windows.h>
#include <stdio.h>
#include <ctype.h>
#include "signal.h"
#include "../include/jmotion.h"

/*
robm
proj>prop>config prop >c/c++>general> add include path
proj>prop>config prop >c/c++>advanced> compile as C
proj>prop>config prop >c/c++ no precompiled headers
enable c++ exceptions
*/

JointSet Init_pos = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
JointSet Des_pos = { 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 0.0, 0.0 };
int Jmg_rate = 30;
int Sample = 2;
int pid;
FILE *fin = (FILE *) 0;
FILE *fout = (FILE *) 0;
static FILE *fsession = (FILE *) 0;
static int fds[2];
static long m_id;
static char buff[128];
extern int jointmotion_report;


int child_handler(), parent_handler(), test_switcher(), add_new_pos(),
shutdown(),seg_violation(), inc_mstime(), parse_child_commands(),
move_1_joint();


main(argc, argv)
int argc;
char **argv;
{

int len, in_check, cnt = 0;
char style[2], flag[2];
fin = stdin;
fout = stdout;
jointmotion_debug = jointmotion_report =
jointswitcher_debug = joint_Ttimedebug = 0;
if ( argc-- < 2 )
{ usage();
}
if ( argc > 1 )
{ len = strlen(argv[1]);
if ( *argv[1] != '-' )
{ usage();
}
len--;
if ( *(argv[1]+1) == 'd' )
{
jointmotion_debug = jointswitcher_debug = joint_Ttimedebug = 1;
if ( --len )
{ if ( *(argv[1]+2) == 'r' )
jointmotion_report = 1;
else usage();
}
}
else
{ if ( *(argv[1]+1) == 'r' )
{ jointmotion_report = 1;
if ( --len )
{
if ( *(argv[1]+2) == 'd' )
jointmotion_debug = jointswitcher_debug =
joint_Ttimedebug = 1;
else usage();
}
}
else usage();
}
}
if ( argc > 2 )
{
if ( (fout = fopen(argv[argc],"w+")) <= 0 )
{ giveup("testjmg: cannot open file for writing\n");
}
argc--;
}
if ( (fin = fopen(argv[argc], "r")) <= 0 )
{ giveup("testjmg: cannot open data file for reading\n");
}
if ( pipe(fds) < 0 )
{ perror("testjmg:");
exit(-1);
}
if ( (pid=fork()) == 0 )
{
pid = getppid();
init_jointsystem(&jm0);
current_jointsystem = &jm0;
if ( read_position(fin, &Init_pos, style) == 0 )
{ giveup("testjmg: Input file does not contain proper information
\n");
}
prepare_jointmotion(&jm0, Init_pos, style[0]);
jointmovereq(&jm0);
while ( (in_check = read_position(fin, &Des_pos, style)) > 0 )
{ prepare_jointmotion(&jm0, Des_pos, style[0]);
cnt = jointmovereq(&jm0);
}
if ( in_check != EOF )
{ giveup("testjmg: Input file does not contain proper information
\n");
}
if ( jointmotion_debug )
{
fprintf(fout, "%ld motions are initially in the queue\n", cnt);
}
signal(SIGINT, child_handler);
signal(SIGUSR1, parse_child_commands);
signal(SIGSEGV, seg_violation);
jointscheduler();
kill(pid, SIGUSR1);
while ( 1 )
{ sleep(Sample);
if ( jm0.e.mstime % 32)
{ fflush(fout);
}
jointscheduler();
kill(pid, SIGUSR1);
}
}
else
{ signal(SIGINT, parent_handler);
signal(SIGCHLD, shutdown);
signal(SIGUSR1, inc_mstime);
if ( fout != stdout )
{ strcpy(buff,argv[argc+1]);
strcat(buff, ".session");
if ( (fsession = fopen(buff, "w+")) < 0 )
{ perror("testjmg: ");
fsession = (FILE *) 0;
}
}
while ( 1 )
{
printf("Enter p/s/j/q: ");
scanf("%1s", flag);
parent_proc(*flag);
}
}
}

parent_proc(comm)
char comm;
{
*buff = comm;
switch( comm )
{
case 's':
case 'S':
printf("Enter motion_id cntrl_sig: \n");
read_line(fileno(stdin), buff+1);
send_message(fds[1]);
log_session();
break;
case 'p':
case 'P':
printf("Enter s/a position segt/arrt prev accomp\n");
read_line(fileno(stdin), buff+1);
send_message(fds[1]);
log_session();
break;
case 'j':
case 'J':
printf("Enter type[a | r] j#[0..5] value(in deg): \n");
read_line(fileno(stdin), buff+1);
send_message(fds[1]);
log_session();
break;
case 'q':
case 'Q':
kill(pid, SIGINT);
shutdown();
default:
fprintf(stderr,"Input Not Valid\n");
break;
}
}

send_message(fd)
int fd;
{
write(fd, buff, strlen(buff));
if ( kill(pid, SIGUSR1) < 0 )
{ perror("testjmg: ");
giveup("");
}
}

log_session()
{
if ( fsession != (FILE *) 0 )
{ sprintf(buff+strlen(buff)," @%d", jm0.e.mstime);
fprintf(fsession,"%s\n", buff);
}
}

read_position(fp, pos, s)
FILE *fp;
JointSet *pos;
char *s;
{
int n;

if ( (n=fscanf(fp, "%1s%f%f%f%f%f%f%f%f%f",
s,
&pos->j1, &pos->j2, &pos->j3, &pos->j4, &pos->j5, &pos->j6,
&jm0.specs.segtime,
&jm0.specs.preview,
&jm0.specs.accomp)) < 0 && n != EOF)
{ giveup("read_position: Error reading input\n");
}
if ( n < 10 && n != EOF )
{ fprintf(stderr,"not enough input\n");
n = 0;
}
return ( n );
}

read_position_interactively(fd, pos, s)
int fd;
JointSet *pos;
char *s;
{
int n;

read_line(fd, buff);
if ( (n=sscanf(buff, "%1s%f%f%f%f%f%f%f%f%f",
s,
&pos->j1, &pos->j2, &pos->j3, &pos->j4, &pos->j5, &pos->j6,
&jm0.specs.segtime,
&jm0.specs.preview,
&jm0.specs.accomp)) < 0 && n != EOF)
{ giveup("read_position: Error reading input\n");
}
if ( n < 10 && n != EOF )
{ fprintf(stderr,"not enough input\n");
n = 0;
}
return ( n );
}

prepare_jointmotion(jm, pos, style)
JointMotionSystem *jm;
JointSet pos;
char style;
{
jm->specs.target = pos;
jm->specs.control = JointGo;
jm->specs.vel = jm->max_vel;
jm->specs.acc = jm->max_acc;
switch ( style )
{
case 'V':
case 'v':
jm->specs.style = JointVelocity;
jm->specs.vel = jm->max_vel;
break;
case 'S':
case 's':
jm->specs.style = JointSegtime;
jm->specs.segtime /= 1000.0;
break;
case 'A':
case 'a':
jm->specs.style = JointArrival;
jm->specs.arrival = jm->specs.segtime / 1000.0; /* info read in
segt */
break;
default:
fprintf(stderr,
"testjmg: JointMotionStyle not valid. Using JointSegtime\n");
jm->specs.style = JointSegtime;
jm->specs.segtime = (rand() % 32) / 1000.0;
return -1;
}
return 0;
}

static flush_joint_queue(q)
Queue *q;
{
JointMotion *pm;

while ( ( pm = (JointMotion *) QueueMoveout(q, JointMotion) ) !=
Null )
{
print_jointmotion(pm);
QueueCheckout(q, JointMotion);
}
}

print_jointmotion(pm)
JointMotion *pm;
{
fprintf(fout, "id = %ld\n", pm->id);
print_joints_by_add("target:\n", &(pm->target));
print_joints_by_add("vel:\n", &(pm->vel));
print_joints_by_add("acc:\n", &(pm->acc));
fprintf(fout, "segtime: %f\n", pm->segtime);
fprintf(fout, "arrival: %f\n", pm->arrival);
fprintf(fout, "style: %s\n", JointStyleTranslate(pm->style));
fprintf(fout, "state: %s\n", JointMotionStateTranslate(pm->state));
fprintf(fout, "control: %s\n", JointControlTranslate(pm->control));
fprintf(fout, "status %d\n", pm->status);
fprintf(fout, "expected_status %d\n", pm->expected_status);
fprintf(fout, "velfact %5.3f, accfact %5.3f, prev %5.3f, accomp %5.3f
\n",
pm->vel_factor, pm->acc_factor, pm->preview, pm->accomp);
fprintf(fout, "f0 @0x%x, f1 @0x%x, f2 @0x%x, f3 @0x%x\n",
pm->f0, pm->f1, pm->f2, pm->f3);
}

usage()
{
giveup("Usage: testjmg [-dr] input [output]\n");
}

child_handler()
{
fprintf(stdout,"Interrupted... Bye\n");
fflush(fout);
if ( fout != stdout )
{ fclose(fout);
}
if ( fin != stdin )
{ fclose(fin);
}
exit(0);
}

parent_handler()
{
fprintf(stderr,"testjmg: an INT signal has been received...Bye\n");
kill(pid, SIGINT);
exit(0);
}

parse_child_commands()
{
char flag;

read(fds[0], &flag, 1);
switch ( flag )
{
case 'p':
case 'P':
add_new_pos();
break;
case 'j':
case 'J':
move_1_joint();
break;
case 's':
case 'S':
test_switcher();
break;
default:
fprintf(stderr,"parse_child_command: Unknown Command option\n");
break;
}
if ( signal(SIGUSR1, parse_child_commands) < 0 )
{
perror("parse_child: ");
exit(0);
}
signal(SIGUSR1, parse_child_commands);
}

int test_switcher()
{
JointMotion *m;
char cntrl[2];

read_line(fds[0], buff, 80);
sscanf(buff,"%ld%1s", &m_id, cntrl);
if ( (m=jointgetmad(m_id)) != Null )
{ switch ( *cntrl )
{
case 'G':
case 'g':
m->control = JointGo;
break;
case 'S':
case 's':
m->control = JointSleep;
break;
case 'E':
case 'e':
m->control = JointEnd;
break;
default:
fprintf(stderr,"Unkown control signal! ignored\n");
}
}
else
{
fprintf(stderr,"Motion not in queue\n");
}
}

int add_new_pos()
{
char style[2];

if ( read_position_interactively(fds[0], &Des_pos, style) > 0 )
{
if ( prepare_jointmotion(&jm0, Des_pos, style[0]) < 0 )
{
return (-1);
}
return (jointmovereq(&jm0));
}
return (-1);
}

int move_1_joint()
{
char type[2];
int j;
float val;

read_line(fds[0], buff);
if ( sscanf(buff, "%1s%d%f", type, &j, &val) < 3 )
{ fprintf(stderr, "move_1_joint: Not enough input\n");
return ;
}
if ( j < 0 || j > 5 )
{
fprintf(stderr,"%d is not a valid joint number [0..5]\n", j);
return ;
}
switch ( *type )
{
case 'r':
case 'R':
move_relative_joint(&jm0, j, val);
break;
case 'a':
case 'A':
move_joint(&jm0, j, val);
break;
default:
fprintf("move_1_joint: Unkown motion type. Use 'a(A)' or 'r
(R)'\n");
break;
}
}

read_line(fd, l)
int fd;
char *l;
{
while ( read(fd, l, 1 ) > 0 && *l != '\n' ) l++;
*(++l) = '\0';
}

void shutdown()
{
printf("\nTerminated bye...\n");
if ( fin != stdin ) fclose(fin);
if ( fout != stdout )
{ fflush(fout);
fclose(fout);
}
close(fds[0]);
close(fds[1]);
exit(-1);
}

seg_violation()
{
fprintf(stderr,"Child process: Segmentation violation\n");
exit(0);
}

inc_mstime()
{
jm0.e.mstime += Sample;
signal(SIGUSR1, inc_mstime);
}
 
S

Seebs

I get these errors when i try to compile some c code I am trying to
port to win32 . I would like to overide the built in shutdown() fn
and use the one in the code here. any ideas on how to get by this
( see full code below)
Yes.

Error 11 error C2373: 'shutdown' : redefinition; different type
modifiers c:\projects\jmotion\jmotion\jmotion.c 30

Change the name of your function if it clashes with something provided
by the environment, or tell your compiler to go into a more strictly
conforming mode.

-s
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top