Re: C programming on ARM



Wilco Dijkstra wrote:
"Grant Edwards" <grante@xxxxxxxx> wrote in message news:13q21msqkij3dbb@xxxxxxxxxxxxxxxxxxxxx
so casting pointers just works.

Unless the resulting pointer is misaligned.

Or the pointer is aligned but points to the wrong place, or invalid memory,
or a peripheral, or ... If you don't know what you're doing then pointer
casting is likely the least of your problems.

My point was that the bitpatterns of all pointer types are the same for
all addresses in the address space.

If they are in the same address space. "void*" (and therefore "char*")
is guaranteed to be able to point at any data item, but there still are
function pointers, which can live in a completely different address
space. The simplest example is our beloved i386 architecture, where data
pointers can be between 16 and 48 bits, code pointers too, but not
necessarily the same size as the others.


Stefan

.



Relevant Pages

  • Re: Pointers in c
    ... (of validating that a pointer is ok to write to/read from) ... memory is valid because accessing invalid memory causes undefined behaviour ... If might later on be invalidated by a fault in your ... CLC FAQ CLC readme: ...
    (comp.lang.c)
  • Re: Problems with function that returns a pointer to array of strings
    ... then seg faults when printing the first line. ... file_lines is declared as a pointer to a pointer to a char object. ... you first retrieve a pointer to a char object ... is extremely likely to be an invalid memory address (much less the one ...
    (comp.lang.c)
  • Re: Sharing a struct/class/pointer in the data_seg() of a dll?
    ... #pragma data_seg ... I am guessing that it is because the memory past the pointer is not ... I am just thinking of the simplest way to share dynamically growing ...
    (microsoft.public.vc.mfc)
  • Re: is this defined behaviour in C++?
    ... >> Offhand I think you've invoked undefined behaviour at the point of you ... What's the simplest way to obtain a pointer to the start of ... first element of the vector. ... I see your frustration -- you want an array-style pointer to the ...
    (comp.lang.cpp)
  • Re: Dumping an instance
    ... > of it's member attributes, what's the simplest way? ... > just gives a pointer to its location in memory ...
    (comp.lang.python)