pytanie odnośnie zmiennych register

0

ucze sie z ksiązki "Programowani w jezykach C i C++ z wykorzystaniem pakietu Borland C++" A.Zalwskiego. tam jest napisane że pobranie adresu ze zmiennej register jest błędne, ale:
#include<stdio.h>
int main(void)
{
register int c;
int *x=&c;
*x=4;
printf("%d",c);
scanf("%d",&c);

}
kod tego programu dział i wysietla poprawnie 4 ;/

0

AFAIK nie można pobrać adresu zmiennej register, bo adresowanie jest inne. Dlaczego się kompiluje? nie wiem

0

A to co:
E:\Marcin\temp\2005-08-04>g++ -W -Wall -pedantic reg.cpp
reg.cpp: In function int main()': reg.cpp:5: warning: address requested for c', which is declared `register'
??

Ty czytasz, czy coś innego robisz z tą książką?? :>

3.11.2 (str. 106)
(...)Kompilator może, lecz nie musi umieścić zmiennej w rejestrze(...)

A po tym

&c

to na pewno nie umieści w rejestrze...

C++ Standard napisał(a)

7.1.1 Storage class specifiers
(...)
3 A register specifier has the same semantics as an auto specifier together with a hint to the implementation that the object so declared will be heavily used. [Note: the hint can be ignored and in most implementations it will be ignored if the address of the object is taken. ?end note]

0

<quote=marcinEc>

Ty czytasz, czy coś innego robisz z tą książką?? :>
<quote>

świetny tekst :D

1 użytkowników online, w tym zalogowanych: 0, gości: 1