[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Stack problems with GCC 4



Roger Burrows wrote:
Hi!
On 24 Dec 2007 at 15:47, josephus wrote:
I am trying to malloc a pointer to a file. that should not be illegal but the messages are confusing. if I just stick the malloc in the pointer I get OTHER ERRORS.


 when I use that  ptr  I get   this

   (FILE *) prt =  fopen(....)

   lvalue casts are deprecated.
if i delete the (FILE *) i get pointer conversion to int without a cast,

   here I am trying to open a file.

are you sure this error condition is not a bug. I cant find any configuration to remove the warnings.


I think you can be sure that this particular error message is there to tell you that you are doing something wrong. The difficulty of course is always figuring out exactly what ...

I'm not sure what exactly you are trying to do. Normally you declare a file handle as a static or dynamic variable in your code, e.g.

FILE *input;

then you open the file with:

	input = fopen(....);

and afterwards you fread/fwrite etc to 'input'.

You *could* do the following as well:

FILE **inputptr;

	inputptr = (FILE **) malloc(sizeof(FILE *));
	*inputptr = fopen(...);

and afterwards you fread/fwrite to '*inputptr' ... but this is pointlessly confusing IMHO.

Roger Burrows
I understand. I have a K&R reference that says before you can put data into a pointer you must malloc that pointer. I am opening a passed in file name. I started with
 FILE * ptr;

but I got a sigerr when I opened the file. to fix the sig err I malloced the pointer ptr. the sig err went away.

sigerrs are the most useless linux error. it tells you nothing. I sometimes get spontaneous sigerrs. some I can fix and some I cannot. it works now, wait and hold your mouth right and it will fail. no changes in environment. so I end up trying to make it work. for a while I had a bad pointer. but some are sys calls with bad arguments and some are not.. and I have 4 or 5 warnings that I don't know how to fix. the casting REQUIREMENT for C is the bane of my life. I have a working K&R compiler. which will let you do what you say. GCC does not. I also used Lattice C and it made many change requirements to compile K&R code, mostly adding casting in rediculus places. lattice was supposed to be ISO compliant.

If I make a mistake in my memory management, it will trap in the library and kill the stack. fixing it is trial and error. there are changes that irritate me just because I expect it to work the same as that K&R compiler.

josephus

--
I go sailing in the Summer and look at STARS in the Winter.
"Everybody is igernant, only on differt subjects"
Will Rogers "it aint what you know that gets you in trouble
it is what you know that aint so"
   Josh Billings.