[問題] volatile void cast
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
aio.h
問題(Question):
aio.h 的 struct aiocb 之中有個 volatile void *aio_buf;
我這樣寫:
int* buffer = new int[100];
unsigned long long int sum(0);
...
cb.aio_buf = buffer;
...
for(int i=0; i<100; i++)
sum+ = (unsigned long long int)cb.aio_buf[i]; //這行出現錯誤
...
錯誤結果(Wrong Output):
code.cpp: In function 'int main()':
code.cpp:46: error: expected primary-expression before '=' token
code.cpp:46: error: pointer of type 'void *' used in arithmetic
code.cpp:46: error: 'volatile void*' is not a pointer-to-object type
程式碼(Code):(請善用置底文網頁, 記得排版)
http://ppt.cc/BVnj
補充說明(Supplement):
http://ppt.cc/5C8d (aio.h)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.124.107.50
→
10/27 02:38, , 1F
10/27 02:38, 1F
推
10/27 12:16, , 2F
10/27 12:16, 2F
感謝XD 不過這樣只改進了第一個error 剩下兩個仍舊
※ 編輯: morris0117 來自: 59.124.107.50 (10/27 13:07)
→
10/27 13:17, , 3F
10/27 13:17, 3F
→
10/27 13:18, , 4F
10/27 13:18, 4F
→
10/27 13:19, , 5F
10/27 13:19, 5F
→
10/27 13:20, , 6F
10/27 13:20, 6F
推
10/30 10:44, , 7F
10/30 10:44, 7F