Re: [LAD] C - Change in memory causing seg.fault (but why?)

From: Robin Gareus <robin@email-addr-hidden>
Date: Sat Nov 10 2012 - 19:54:43 EET

On 11/10/2012 10:35 AM, John Rigg wrote:
> On Fri, Nov 09, 2012 at 03:24:56PM +0100, Muffinman wrote:
>> Yeah, that explains why I didn't get any compiling error on a 32bit
>> computer and did get on a 64bit one (where I did correct the error).
>> However, the latter was satisfied with %li. Apparently in c++ there is
>> no difference between long and long int (as far as I can find through
>> Google) but for c I could not find much info on a potential difference.
>
> long is the same as long int in both. The problem is that int and long int
> are both 32 bits on i386, but on x86-64 int is 32 and long int is 64 bits.

spot on. It's architecture dependent. Here's an index:

http://www.makelinux.net/ldd3/chp-11-sect-1

For printing, one can use <inttypes.h>
  printf("val=" PRId64 "\n", (int64_t) val);

The only problematic one is size_t. printf's %z %Z is a GNU libc extension.

Back on topic, a good general introduction to pointers, malloc etc is
http://cslibrary.stanford.edu/102/PointersAndMemory.pdf

ciao,
robin
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Sat Nov 10 20:15:02 2012

This archive was generated by hypermail 2.1.8 : Sat Nov 10 2012 - 20:15:02 EET