0
注意:我正在使用Xcode最新版本附帶的目標C編譯器。爲什麼我可以修改const __restrict指針而不是typdef'd版本?
爲什麼說這是合法的:
void verySpecial(const float* __restrict foo, const int size) {
for (int i = 0; i < size; ++i) {
// ... do special things ...
++foo; // <-- Should be illegal to modify const pointer?
}
}
但是,如果我使用typedef,它做什麼,我認爲它應該做的。
typedef float* __restrict RFloatPtr;
void verySpecial(const RFloatPtr foo, const int size) {
for (int i = 0; i < size; ++i) {
// ... do special things ...
++foo; // <-- Now this is a compiler error.
}
}
那麼,什麼是在typedef定義不同的情況下,什麼不我明白?閱讀__restrict會讓我的大腦受到傷害,我甚至不確定這是否重要。
First Apple's沒有使用gcc或llvm的objective-c編譯器。 –
@AnoopVaidya哼,什麼? – 2013-04-17 17:50:07
無論如何。這是XCode附帶的編譯器。應用商店中最新版本的XCode。 –