5 Fehler beim Compilieren mit der PSDK



  • Hi

    Ich habe folgendes Codebeispiel mal versucht zu compilieren:
    http://www.c-plusplus.net/forum/viewtopic-var-p-is-616637.html#616637

    Bekomme aber immer folgende Fehlermitteilung:

    1>------ Erstellen gestartet: Projekt: seriCPU, Konfiguration: Debug Win32 ------
    1>Kompilieren...
    1>main.cpp
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(513) : warning C4996: '_vsnprintf': This function or variable may be unsafe. Consider using _vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdio.h(339) : see declaration of '_vsnprintf'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(526) : warning C4793: 'vararg' : causes native code generation for function 'void ATL::AtlTrace(LPCSTR,...)'
    1>        C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(505) : see declaration of 'ATL::AtlTrace'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(537) : warning C4996: '_vsnprintf': This function or variable may be unsafe. Consider using _vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdio.h(339) : see declaration of '_vsnprintf'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(551) : warning C4793: 'vararg' : causes native code generation for function 'void ATL::AtlTrace2(DWORD,UINT,LPCSTR,...)'
    1>        C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(527) : see declaration of 'ATL::AtlTrace2'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(561) : warning C4996: '_vsnwprintf': This function or variable may be unsafe. Consider using _vsnwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\wchar.h(719) : see declaration of '_vsnwprintf'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(573) : warning C4793: 'vararg' : causes native code generation for function 'void ATL::AtlTrace(LPCWSTR,...)'
    1>        C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(553) : see declaration of 'ATL::AtlTrace'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(584) : warning C4996: '_vsnwprintf': This function or variable may be unsafe. Consider using _vsnwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\wchar.h(719) : see declaration of '_vsnwprintf'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(598) : warning C4793: 'vararg' : causes native code generation for function 'void ATL::AtlTrace2(DWORD,UINT,LPCWSTR,...)'
    1>        C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(574) : see declaration of 'ATL::AtlTrace2'
    1>..\src\main.cpp(74) : error C2664: 'ATL::CRegKey::Open' : cannot convert parameter 2 from 'const char [53]' to 'LPCTSTR'
    1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>..\src\main.cpp(77) : error C2664: 'LONG ATL::CRegKey::SetValue(DWORD,LPCTSTR)' : cannot convert parameter 2 from 'const char [29]' to 'LPCTSTR'
    1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>..\src\main.cpp(135) : error C2664: 'LONGLONG CPerfCounters<T>::GetCounterValue(PERF_DATA_BLOCK **,DWORD,DWORD,LPCTSTR)' : cannot convert parameter 4 from 'char [256]' to 'LPCTSTR'
    1>        with
    1>        [
    1>            T=LONGLONG
    1>        ]
    1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>..\src\main.cpp(178) : error C2664: 'strcpy' : cannot convert parameter 2 from 'LPCTSTR' to 'const char *'
    1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>..\src\main.cpp(185) : error C2664: 'LONGLONG CPerfCounters<T>::GetCounterValue(PERF_DATA_BLOCK **,DWORD,DWORD,LPCTSTR)' : cannot convert parameter 4 from 'char [256]' to 'LPCTSTR'
    1>        with
    1>        [
    1>            T=LONGLONG
    1>        ]
    1>        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
    1>Das Buildprotokoll wurde unter "file://c:\Users\Christian\Documents\Projects\seriCPU\seriCPU\Debug\BuildLog.htm" gespeichert.
    1>seriCPU - 5 Fehler, 8 Warnung(en)
    ========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
    

    Ich benutze VC++ 2005 express edition sp1 mit vista update und die PSDK WINDOWS SERVER 2003 R2

    Ich hoffe ihr könnt mir helfen.



  • Du solltest vielleicht den code Zeigen 😉 Und nicht einen Link zu einem Icon post 🙂



  • Oh entschuldige habe das Falsche kopiert hier der Link:
    http://www.c-plusplus.net/forum/viewtopic-var-p-is-616637.html#616637



  • Dein Projekt hat UNICODE aktiviert, der Code ist aber nicht auf Unicode angepasst 😉



  • Ok habe den Zeichensatz auf Multi-Byte-Zeichensatz gestellt.
    Jetzt kommt folgende Meldung:

    1>------ Erstellen gestartet: Projekt: seriCPU, Konfiguration: Debug Win32 ------
    1>Kompilieren...
    1>main.cpp
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(513) : warning C4996: '_vsnprintf': This function or variable may be unsafe. Consider using _vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdio.h(339) : see declaration of '_vsnprintf'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(526) : warning C4793: 'vararg' : causes native code generation for function 'void ATL::AtlTrace(LPCSTR,...)'
    1>        C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(505) : see declaration of 'ATL::AtlTrace'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(537) : warning C4996: '_vsnprintf': This function or variable may be unsafe. Consider using _vsnprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdio.h(339) : see declaration of '_vsnprintf'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(551) : warning C4793: 'vararg' : causes native code generation for function 'void ATL::AtlTrace2(DWORD,UINT,LPCSTR,...)'
    1>        C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(527) : see declaration of 'ATL::AtlTrace2'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(561) : warning C4996: '_vsnwprintf': This function or variable may be unsafe. Consider using _vsnwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdio.h(450) : see declaration of '_vsnwprintf'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(573) : warning C4793: 'vararg' : causes native code generation for function 'void ATL::AtlTrace(LPCWSTR,...)'
    1>        C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(553) : see declaration of 'ATL::AtlTrace'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(584) : warning C4996: '_vsnwprintf': This function or variable may be unsafe. Consider using _vsnwprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\stdio.h(450) : see declaration of '_vsnwprintf'
    1>C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(598) : warning C4793: 'vararg' : causes native code generation for function 'void ATL::AtlTrace2(DWORD,UINT,LPCWSTR,...)'
    1>        C:\Program Files (x86)\Microsoft Platform SDK\Include\atl\atlbase.h(574) : see declaration of 'ATL::AtlTrace2'
    1>..\src\main.cpp(124) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\string.h(74) : see declaration of 'strcpy'
    1>..\src\main.cpp(178) : warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\string.h(74) : see declaration of 'strcpy'
    1>C:\Users\Christian\Documents\Projects\seriCPU\include\PerfCounters.h(170) : warning C4996: 'stricmp': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _stricmp. See online help for details.
    1>        C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\string.h(215) : see declaration of 'stricmp'
    1>        C:\Users\Christian\Documents\Projects\seriCPU\include\PerfCounters.h(135) : while compiling class template member function 'LONGLONG CPerfCounters<T>::GetCounterValue(PPERF_OBJECT_TYPE,DWORD,LPCTSTR)'
    1>        with
    1>        [
    1>            T=LONGLONG
    1>        ]
    1>        ..\src\main.cpp(101) : see reference to class template instantiation 'CPerfCounters<T>' being compiled
    1>        with
    1>        [
    1>            T=LONGLONG
    1>        ]
    1>Verknüpfen...
    1>LINK : fatal error LNK1104: cannot open file 'atlthunk.lib'
    1>Das Buildprotokoll wurde unter "file://c:\Users\Christian\Documents\Projects\seriCPU\seriCPU\Debug\BuildLog.htm" gespeichert.
    1>seriCPU - 1 Fehler, 11 Warnung(en)
    ========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========
    


  • Du stellst vermutlich ein VC6 projekt um...
    Ich rate dann dazu Folgendes zu definieren:
    _CRT_SECURE_NO_WARNINGS

    Und stell Dein Projekt wieder auf "ANSI" um... (oder Multi-ByteCharcter)!

    AFAIK gibt es atlthunk auch nicht mehr...
    http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/c8298f5b-bdee-4707-990c-046f3c3dfe71



  • Habe mit den Link von atltunk.lib durch gelesen. Und das was der ganz unten sagt auch mal ausprobiert. Bekomme dann aber trotzdem einen Linkererror.
    Gib es vielleicht eine Möglichkeit dieses Projekt so um zu bauen das es funktioniert?



  • I also had error C2664 when I tried to build as debug. There were incompatible settings in Visual Studio 8. I use the following settings to fix it:

    configuration properties > general > Use of MFC = Use Standard Windows Libraries (I'm building a static lib)

    configuration properties > general > Character Set = Use Multi-Byte (this was Unicode when the error occured)

    😃 Thank you for pointing me in the right direction!

    Mit freundlichen Grüβen
    xo byte ranger


Anmelden zum Antworten