[Prev][Next][Index]
Problems with simple C program
- Date: Tue, 12 Jul 1994 18:17:14 -0600
- From: Diego Novillo <diego@cs.ualberta.ca>
- Subject: Problems with simple C program
- To: sage-bugs@cica.indiana.edu
Hi,
I have got SAGE v1.3.1 and I'm trying to learn how it works.
Since I haven't found anything in the documentation about creating .dep
files from C source code, I tried using c2dep on a simple C program
(included below) but it gave back the error message "Error on line 0 of
(null): invalid #line"
After that, I tried using 'vcc' which first calls the C
pre-processor, but I got the following error message:
sh: 20455 Memory fault
rm: XX_vpc_tmp.dep: No such file or directory
The memory fault is caused by 'c2dep' when it tries to parse the
generated file.
At last, I tried pC++2dep, on the file generated by cpp and it
didn't core dump but it produced the following error:
Warning on line 33 of filter.c: illegal type combination
Error on line 48 of filter.c: not a proper member or union/struct requierd
The problem was with the 'putchar()' macro. So I removed it and
finally it worked. However, I think that there's something I'm not doing
right. Could you please help me out with this problem? What is the right
way of generating .dep files from C source code?
Thanks a lot. Diego.
------ filter.c --- Just a toy program to see how Sage works ---------------
#include <stdio.h>
#include <stdlib.h>
main(int argc, char *argv[])
{
FILE *file;
char *name;
int width;
if (argc == 1)
{
fprintf(stderr, "\n");
fprintf(stderr, "%s - Filters out control characters\n", argv[0]);
fprintf(stderr, "Usage: %s [-num] file\n", argv[0]);
fprintf(stderr, " num: Specifies number of characters per line\n");
fprintf(stderr, " Default = 80.\n");
fprintf(stderr, "\n");
exit(1);
}
else
{
if (argc == 3)
{
name = argv[2];
width = atoi(argv[1]);
}
else
{
name = argv[1];
width = 80;
}
file = fopen(name, "rb");
if (file == NULL)
{
fprintf(stderr, "%s: Can't open file '%s' for input\n", argv[0], name);
exit(1);
}
else
{
int nchars = 1;
while (!feof(file))
{
char t = getc(file);
if (t >= 32 || t == '\n' || t == '\t')
{
putchar(t);
if (t == '\n') nchars = 1;
nchars++;
if (nchars == width)
{
putchar('\n');
nchars = 1;
}
}
}
fclose(file);
}
}
}
----------------------------------------------------------------------------
--
Diego A. Novillo | "We each pay a fabulous price for our
diego@cs.ualberta.ca | visions of paradise. But a spirit with
Computing Science - U of Alberta | a vision is a dream with a mission"
Edmonton, Alberta - Canada | Rush - Mission
Follow-Up(s):