PGS-MSI Temat założony przez niniejszego użytkownika |
Problem z dzieleniem kodu na osobne pliki. » 2013-04-06 18:09:41 Witam Napisałem sobie taki bardzo prosty program w WinApi i chciałem podzielić kod na pliki. I po podziale kompilator nie pokazuje błędów zaś debugger coś takiego w okienku komunikatu: Kompilator: Visual Studio Express 2012 "Run-Time Check Failure #3 - The variable 'zwroc' is being used without being initialized." A to w log'u: 'Projekt3.exe' (Win32): Loaded 'C:\Users\Michal\Desktop\VS c++\Projekt3_1\Debug\Projekt3.exe'. Symbols loaded. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\uxtheme.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Program Files (x86)\MSI Afterburner\Bundle\OSDServer\RTSSHooks.dll'. Module was built without symbols. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\dwmapi.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\oleaut32.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Program Files (x86)\OSCAR Editor X7\dll\DLL_Wheel4D.dll'. Cannot find or open the PDB file. 'Projekt3.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msimg32.dll'. Cannot find or open the PDB file. Run-Time Check Failure #3 - The variable 'zwroc' is being used without being initialized. The program '[3292] Projekt3.exe' has exited with code 0 (0x0).
Program: #include <windows.h> #include <string> #include <sstream>
#include "case_1.h" using namespace std; #define ID_PRZYCISK1 501 #define ID_PRZYCISK2 502
HWND hText; HWND hText1; HWND hText2; LPSTR test;
LPSTR NazwaKlasy = "Klasa Okienka"; MSG Komunikat;
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { WNDCLASSEX wc; wc.cbSize = sizeof( WNDCLASSEX ); wc.style = 0; wc.lpfnWndProc = WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon( NULL, IDI_APPLICATION ); wc.hCursor = LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground =( HBRUSH )( COLOR_WINDOW + 1 ); wc.lpszMenuName = NULL; wc.lpszClassName = NazwaKlasy; wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); if( !RegisterClassEx( & wc ) ) { MessageBox( NULL, "Wysoka Komisja odmawia rejestracji tego okna!", "Niestety...", MB_ICONEXCLAMATION | MB_OK ); return 1; } HWND hwnd; hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, NazwaKlasy, "Oto okienko", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, NULL, NULL, hInstance, NULL ); if( hwnd == NULL ) { MessageBox( NULL, "Okno odmówiło przyjścia na świat!", "Ale kicha...", MB_ICONEXCLAMATION ); return 1; } HWND hButton1 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "Pierwszy", WS_CHILD | NULL | WS_BORDER, 20, 20, 150, 30, hwnd,( HMENU ) ID_PRZYCISK1, hInstance, NULL ), hButton2 = CreateWindowEx( WS_EX_CLIENTEDGE, "BUTTON", "Drugi", WS_CHILD | WS_VISIBLE | WS_BORDER, 20, 50, 150, 30, hwnd,( HMENU ) ID_PRZYCISK2, hInstance, NULL ); hText = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 170, 20, 150, 30, hwnd, NULL, hInstance, NULL ); hText1 = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 170, 50, 150, 30, hwnd, NULL, hInstance, NULL ); hText2 = CreateWindowEx( WS_EX_CLIENTEDGE, "EDIT", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 170, 80, 150, 30, hwnd, NULL, hInstance, NULL ); ShowWindow( hwnd, nCmdShow ); UpdateWindow( hwnd ); while( GetMessage( & Komunikat, NULL, 0, 0 ) ) { TranslateMessage( & Komunikat ); DispatchMessage( & Komunikat ); } return Komunikat.wParam; }
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { stringstream strumien; INT16 wynik_int; LPSTR a; LPSTR b; LPSTR wynik; switch( msg ) { case WM_COMMAND: { switch( wParam ) { case ID_PRZYCISK1: { break; } case ID_PRZYCISK2: { DWORD dlugosc = GetWindowTextLength( hText ); a =( LPSTR ) GlobalAlloc( GPTR, dlugosc + 1 ); GetWindowText( hText, a, dlugosc + 1 ); DWORD dlugosc1 = GetWindowTextLength( hText1 ); b =( LPSTR ) GlobalAlloc( GPTR, dlugosc + 1 ); GetWindowText( hText1, b, dlugosc + 1 ); wynik = suma_1( a, b ); SetWindowText( hText2, wynik ); break; } } break; } case WM_CLOSE: DestroyWindow( hwnd ); break; case WM_DESTROY: PostQuitMessage( 0 ); break; default: return DefWindowProc( hwnd, msg, wParam, lParam ); } return 0; }
#include <windows.h> #include <string> #include <sstream> #include "case_1.h" using namespace std;
LPSTR suma_1( LPSTR a, LPSTR b ) { LPSTR zwroc; INT16 a_int = 0; INT16 b_int = 0; INT16 suma = 0; stringstream strumien; strumien << a; strumien >> a_int; strumien.clear(); strumien.sync(); strumien << b; strumien >> b_int; strumien.clear(); strumien.sync(); suma = a_int + b_int; strumien << suma; strumien >> zwroc; return zwroc; }
#ifndef _case_1_HPP #define _case_1_HPP
LPSTR suma_1( LPSTR a, LPSTR b );
#endif
W jakie znaczniki wkleja się kod z debuggera? |