Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Системное программирование и WinAPI > проблема с хедером


Автор: knut 10.9.2007, 14:51
Добрый день.
вот вклучаю хедер и получаю ошибку 
#include "afxdisp.h"
Цитата

fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include 
<windows.h>



p.s в проекте не где не включенны ни какие "windows.h" 

Автор: zkv 10.9.2007, 15:16
Цитата(knut @  10.9.2007,  14:51 Найти цитируемый пост)
в проекте не где не включенны ни какие "windows.h"  

а косвенно? те подключил файл, в котором подключен windows.h

Автор: yar 10.9.2007, 15:25
Попробуйте поставить этот include либо перед всеми остальными, либо после.

Автор: knut 10.9.2007, 15:46
yar, 
поставил я инклуд в самое начало stdafx.h фаила и получил ошибки
Цитата

error C2146: syntax error : missing ';' before identifier 'HwndMSWheel'    
error C2433: 'HWND' : 'inline' not permitted on data declarations    
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    
error C2065: 'PUINT' : undeclared identifier  
error C2146: syntax error : missing ')' before identifier 'puiMsh_MsgMouseWheel'    
 
а если в конец то та же ошибка что в начале

zkv, 
вот те все файлы каторые у меня в прекомпил хедере 
#include <atlbase.h>
#include <atlcom.h>
и где я косвенно подклучаю windows.h?

Автор: zkv 10.9.2007, 16:08
Цитата(knut @  10.9.2007,  15:46 Найти цитируемый пост)
и где я косвенно подклучаю windows.h? 

тута:
Цитата(knut @  10.9.2007,  15:46 Найти цитируемый пост)
#include <atlbase.h>

поясняю:
atlbase.h содержит:
Код

#include <atlcore.h>

atlcore.h содержит:
Код

#include <windows.h>

делай так:
Код

#include <afxwin.h>
#include <afxdisp.h>

#include <atlbase.h>
#include <atlcom.h>

Автор: knut 10.9.2007, 16:43
zkv, 
зделал как ты сказал но на выходе опять error ы
Цитата

error C2146: syntax error : missing ';' before identifier 'HwndMSWheel'
error C2433: 'HWND' : 'inline' not permitted on data declarations    
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    141
error C2065: 'PUINT' : undeclared identifier    
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    
Error    7    error C2059: syntax error : ')'    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    147    
Error    8    error C2143: syntax error : missing ';' before '{'    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    148    
Error    9    error C2447: '{' : missing function header (old-style formal list?)    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    148    
Error    10    error C2146: syntax error : missing ';' before identifier 'HRESULT'    c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h    29    
Error    11    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h    29    
Error    12    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h    29    
Error    13    error C2065: 'CALLBACK' : undeclared identifier    c:\program files\microsoft visual studio 8\vc\platformsdk\include\prsht.h    97    
Error    14    error C2065: 'LPFNPSPCALLBACKA' : undeclared identifier    c:\program files\microsoft visual studio 8\vc\platformsdk\include\prsht.h    97    
Error    15    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\program files\microsoft visual studio 8\vc\platformsdk\include\prsht.h    97    
Error    16    fatal error C1903: unable to recover from previous error(s); stopping compilation    c:\program files\microsoft visual studio 8\vc\platformsdk\include\prsht.h    97    


Автор: zkv 10.9.2007, 16:58
проверил, у меня даже так работает (VC++8.0):
Код

#include <afxdisp.h>
#include <atlbase.h>
#include <atlcom.h>

так что не могу помочь больше, попробуй локализовать на тестовом проекте, может с precompiled headers ошибка связана?

Автор: knut 11.9.2007, 10:57
zkv, 
что с моим компилером версия(VC++8.0) вот создаю простое преложение (МФЦ)
собираю а компилятор жалуется
Цитата

Error    1    error C2146: syntax error : missing ';' before identifier 'HwndMSWheel'    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    141    
Error    2    error C2433: 'HWND' : 'inline' not permitted on data declarations    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    141    
Error    3    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    141    
Error    4    error C2065: 'PUINT' : undeclared identifier    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    142    
Error    5    error C2146: syntax error : missing ')' before identifier 'puiMsh_MsgMouseWheel'    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    142    
Error    6    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    142    
Error    7    error C2059: syntax error : ')'    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    147    
Error    8    error C2143: syntax error : missing ';' before '{'    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    148    
Error    9    error C2447: '{' : missing function header (old-style formal list?)    c:\program files\microsoft visual studio 8\vc\platformsdk\include\zmouse.h    148    
Error    10    error C2146: syntax error : missing ';' before identifier 'HRESULT'    c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h    29    
Error    11    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h    29    
Error    12    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\program files\microsoft visual studio 8\vc\platformsdk\include\commctrl.h    29    
Error    13    error C2065: 'CALLBACK' : undeclared identifier    c:\program files\microsoft visual studio 8\vc\platformsdk\include\prsht.h    97    
Error    14    error C2065: 'LPFNPSPCALLBACKA' : undeclared identifier    c:\program files\microsoft visual studio 8\vc\platformsdk\include\prsht.h    97    
Error    15    error C4430: missing type specifier - int assumed. Note: C++ does not support default-int    c:\program files\microsoft visual studio 8\vc\platformsdk\include\prsht.h    97    
Error    16    fatal error C1903: unable to recover from previous error(s); stopping compilation    c:\program files\microsoft visual studio 8\vc\platformsdk\include\prsht.h    97    


в чем дело?

Автор: Nastya 11.9.2007, 11:15
В свойствах проекта стоит что ты используешь MFC ?

Автор: zkv 11.9.2007, 11:23
Цитата(knut @  11.9.2007,  10:57 Найти цитируемый пост)
в чем дело? 

трудно сказать. 
Я не могу воссоздать ошибку - у меня все работает. 
А как я могу ответить на не заданный вопрос?

Возможно дефайн где-то затесался ненужный типа WIN32(или наподобие)
В настройках проекта в precompiled header что стоит?

Добавлено через 1 минуту и 44 секунды
Цитата(Nastya @  11.9.2007,  11:15 Найти цитируемый пост)
В свойствах проекта стоит что ты используешь MFC ? 

на этапе компиляции это не важно smile

Автор: knut 11.9.2007, 11:32
Nastya, 
да(configuration property->General->Prop.Def.->use of MFC  -Use MFC in a Shared DLL)
zkv, 
Цитата

В настройках проекта в precompiled header что стоит? 

c/c++ ->precompiled header ->precompiled header file -$(IntDir)\$(TargetName).pch
c/c++ ->precompiled header ->create/use precompiled header  - Use Precompiled Header (/Yu)


Автор: zkv 11.9.2007, 15:05
knut, проблема не в precompiled header.
нужно больше инфы.
Создай проект, в нем создай теже файлы, подключи теже хидеры, что в твоем проекте (вообщем нужно воссоздать ошибку), если ошибка останется - выкладывай.

Автор: knut 11.9.2007, 15:49
zkv, 
я созал простой (пустой)мфц  проект подключаю  #include <afxdisp.h> и те же ошибки  smile .

Добавлено через 2 минуты и 54 секунды
все ошибки на эту функц.
Код

__inline HWND HwndMSWheel(
      PUINT puiMsh_MsgMouseWheel,
      PUINT puiMsh_Msg3DSupport,
      PUINT puiMsh_MsgScrollLines,
      PBOOL pf3DSupport,
      PINT  piScrollLines
)

Автор: zkv 11.9.2007, 16:01
Цитата(knut @  11.9.2007,  15:49 Найти цитируемый пост)
я созал простой (пустой)мфц  проект подключаю  #include <afxdisp.h> и те же ошибки

выложи этот проект сюда, посмотрим
оставь только файлы: sln, vcproj, cpp, h, rc и всю папку res.
Заархивируй и выкладывай.

Автор: yar 11.9.2007, 16:04
А что говорит компилятор, если ему поставить директиву /showIncludes ?.

Похожая проблема http://www.thescripts.com/forum/thread263082.html.
zmouse.h должен инклюдится после  windows.h.

Автор: zkv 11.9.2007, 23:46
Цитата(yar @  11.9.2007,  16:04 Найти цитируемый пост)
Похожая проблема здесь

угу  smile 

Автор: knut 12.9.2007, 14:05
народ уже 2 ой день мучаюсь  теперь такая ошибка.
Цитата

fatal error C1189: #error :  Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]    C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\afx.h    24    

вот прекрепил фаил 

Автор: yar 12.9.2007, 14:14
Свойства проекта -> Configuration Proporties -> General -> Use of MFC
Поставь Use MFC in a Shared DLL.

Автор: zkv 12.9.2007, 14:25
если хочешь статические, то С/С++->Code generation->Runtime library поставь в Multi-threaded (дебаг или нет - в зависимоти от сборки)

Автор: knut 12.9.2007, 14:28
yar, 
так тоже химичил но вот результат
Цитата

error LNK2005: _DllMain@12 already defined in SimpleProject.obj    mfcs80ud.lib    
error LNK1169: one or more multiply defined symbols found    c:\Documents and Settings\SergeyAzizbekyanc\Desktop\SimpleProject\SimpleProject\Debug\SimpleProject.dll    1


Добавлено через 5 минут и 45 секунд
zkv
Цитата

Multi-threaded Debug DLL (/MDd)


Автор: zkv 12.9.2007, 14:39
Multi-threaded Debug (/MTd)

Автор: knut 12.9.2007, 14:47
zkv, 
Multi-threaded Debug (/MTd)  и получаем 
Цитата

fatal error C1189: #error :  Please use the /MD switch for _AFXDLL builds    c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxver_.h    77    


Автор: yar 12.9.2007, 15:06
Цитата(knut @  12.9.2007,  14:28 Найти цитируемый пост)
error LNK2005: _DllMain@12 already defined in SimpleProject.obj    mfcs80ud.lib    error LNK1169: one or more multiply defined symbols found    c:\Documents and Settings\SergeyAzizbekyanc\Desktop\SimpleProject\SimpleProject\Debug\SimpleProject.dll    1


Видно конфликтуют MFC с CRT, DllMain и там, и там объявлена.
Попробуй поменять местами либы линковщику smile

вот что по этому поводу http://support.microsoft.com/kb/148652

Автор: knut 12.9.2007, 19:58
решил проблему так(но решение мне не очень нравится) 
закоменторовал DllMain функц. в своем длл е чтоб не конфликтовала и проблема решилась.
но что значит закоментировать DllMain вxодную функц. xаос какой то .
если у кого то есть вариант боле нормальный прошу выложить.

zkv, 
yar, 
p.s
спасибо   и конечно плюсики в репу. короче respect

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)