0

I have had to switch some functional c code over from a 32 bit machine to a 64 bit machine. I have found some useful links on how to do that (ex. Converting 32-bit Application Into 64-bit Application in C) and so far I have replaced all instances of 'long' with 'int' but I am still encountering problems.

The program compiles but when I run it, it gets stuck. When I force it to close I get a Seg. fault. I have found the exact line where the program gets hung up (i.e. it gets to SheilaTestPoint1 but not SheilaTestPoint2).

    fprintf(stderr, "SheilaTestPoint1");
    check = read(fpheading, &header, 8);
    fprintf(stderr, "SheilaTestPoint2");

Any suggestions on how to proceed?

Thank you!!

Community
  • 1
  • 1
  • I'm guessing that the 8 is the size of `header`, but that may have changed. You should do `sizeof(header)`. But then, if the actual file contains 8 bytes, then you should change the `header` definition to be exactly 8 bytes. – rodrigo Feb 12 '14 at 21:40
  • This is not answerable without seeing the allegedly problematic code in context. – Chris Stratton Feb 12 '14 at 21:41
  • @rodrigo - you are moving towards a good point, which is that if "header" is a structure it's internal format & packing may have changed, quite possibly no longer matching the data in the file. – Chris Stratton Feb 12 '14 at 21:42
  • I'm curious what `read` is. Is it POSIX `read(2)`? `fpheading` looks like a `FILE*` but `open(2)` accepts a file descriptor `int`. Wouldn't you be getting an `EFAULT` rather than a segfault? – Mark Nunberg Feb 12 '14 at 23:27
  • Hey thank you for your help. fpheading is a file handle so it is an int. Also, header is defined in the program earlier as: char header[20]; – user3216648 Feb 19 '14 at 19:38

0 Answers0