|
|
|
Помогите объявить глобальную переменную (не смешно)
|
|||
|---|---|---|---|
|
#18+
При объявлении глобальной переменной получаю ошибку TestClass.obj : error LNK2005: "int globPerem" (?globPerem@@3HA) already defined in testGlobal.obj D:\CVSHome\VCPP\testGlobal\Debug\testGlobal.exe : fatal error LNK1169: one or more multiply defined symbols found Build log was saved at "file://d:\CVSHome\VCPP\testGlobal\testGlobal\Debug\BuildLog.htm" testGlobal - 2 error(s), 0 warning(s) testGlobal.cpp Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. testGlobal.h Код: plaintext 1. 2. 3. 4. testClass.cpp Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. testClass.h Код: plaintext 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. Хелп ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2006, 13:34 |
|
||
|
Помогите объявить глобальную переменную (не смешно)
|
|||
|---|---|---|---|
|
#18+
Оба срр-файла включают testGlobal.h, в котором объявлена переменная globPerem. Получается что в каждом срр-файле есть своя копия этой переменной. Можно обойти так: testGlobal.h: extern int globPerem; testGlobal.cpp: #include "testGlobal.h" int globPerem; //вот тут она размещена ровно один раз testClass.cpp #include "testGlobal.h" ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2006, 14:27 |
|
||
|
Помогите объявить глобальную переменную (не смешно)
|
|||
|---|---|---|---|
|
#18+
ext.h: extern int g_var; ext.cpp: int g_var; Файл ext.h включается всюду, где используется g_var. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2006, 15:58 |
|
||
|
Помогите объявить глобальную переменную (не смешно)
|
|||
|---|---|---|---|
|
#18+
Pardon, I was too late. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 06.11.2006, 16:00 |
|
||
|
|

start [/forum/topic.php?fid=57&msg=34107250&tid=2030109]: |
0ms |
get settings: |
10ms |
get forum list: |
16ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
180ms |
get topic data: |
12ms |
get forum data: |
3ms |
get page messages: |
61ms |
get tp. blocked users: |
2ms |
| others: | 233ms |
| total: | 525ms |

| 0 / 0 |
