Re: why use -> (not .) with pointers?
Felix Kater wrote:
> when accessing the variables in a struct: What's the reason why in C
> you have -> and . instead of only . ?
Historical. I seem to recall . came first, -> came later.
> Are there cases in which the compiler couldn't figure out what to do?
If the language definition said that . would dereferece
pointers, or that -> would work on structures, the compiler
would have no problem implementing it.
Whether that was true for the original implementation of
C (which, do remember, worked in a environment where the
amount of available memory wouldn't even be enough for a
decent *image* on today's machines), I don't know.
It's not likely to change.
--
Chris "electric hedgehog" Dollin
It's called *extreme* programming, not *stupid* programming.
.
Relevant Pages
- Re: komplexes Problem mit Funktionszeigern
... Die Funktion gibt einen struct "by value" zurueck und bei der ... am Borland Compiler, da der Microsoft Compiler ... Man kann Argumente fuer eine Funktion z.B auf dem Stack uebergeben. ... Das funktioniert natuerlich nur fuer "Basis Typen" die in ein Register passen. ... (de.comp.lang.c) - Re: Naming typedefs
... problem that a scalar could be returned in the A register ... to have waste precious cpu cycles copying the struct there ... of the hardware or twentieth century compiler technology. ... # to include the header defining it into every other header (assuming ... (comp.unix.programmer) - Re: assembly language and reverse engineering
... "return arguments to struct pointed to by register" and ... assumptions of CDECL-like conventions (also supports STDCALL, ... arg for handling struct return (slightly compiler, and compiler version, ... (alt.lang.asm) - Re: HardBound and SoftBound (was "The State of Software")
... I will explain to you one last time that the problem is not whether a compiler can generate checks for all buffer overflows. ... By the way, in the last example of such code that I saw, it had been changed to use the address of the struct, not of the first element of the struct: ... to take address of struct rather than address of first element. ... such tricks are used to create a pointer which is then passed on. ... (comp.arch) - Re: C++ in ternms of C
... >about class and struct difference. ... How is the private and public part ... I tried to analise the ASM file produ ced my the VC++ compil er. ... >epresented by the c++ compiler in translation to intermediate stage. ... (microsoft.public.vc.language) |
|