User forums > Help

Errors and warnings

(1/3) > >>

Marcel:
I have Errors and warnings with Code::blocks. On MS VC++ 2005 EE everything's fine.
Im not good at speaking English...

--- Code: ----------------- Build: Debug in Timer ---------------

Compiling: main.cpp
C:\C++\Timer\main.cpp: In function `int main()':
C:\C++\Timer\main.cpp:25: warning: statement has no effect
C:\C++\Timer\main.cpp:32: error: cannot convert `const wchar_t*' to `const CHAR*' for argument `1' to `BOOL PlaySoundA(const CHAR*, HINSTANCE__*, DWORD)'
C:\C++\Timer\main.cpp:41: warning: statement has no effect
C:\C++\Timer\main.cpp:50: warning: statement has no effect
C:\C++\Timer\main.cpp:56: error: cannot convert `const wchar_t*' to `const CHAR*' for argument `1' to `BOOL PlaySoundA(const CHAR*, HINSTANCE__*, DWORD)'
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 3 warnings
--- End code ---

MortenMacFly:

--- Quote from: Marcel on January 25, 2008, 07:50:41 pm ---I have Errors and warnings with Code::blocks. On MS VC++ 2005 EE everything's fine.

--- End quote ---
You won't get any useful answer with such less information.
What C::B version? What compiler (version)? What OS? What application? Provide code. Provide the compile full log (see my sig)...
With regards, Morten.

Marcel:
I Use on Windows Code::Blocks with the newest nightly build. My Compiler ist MinGW Version 5.1.3. I used a console aplication.

--- Code: ----------------- Build: Debug in Timer ---------------

mingw32-g++.exe -Wall -fexceptions  -g     -c C:\C++\Timer\main.cpp -o obj\Debug\main.o
C:\C++\Timer\main.cpp: In function `int main()':
C:\C++\Timer\main.cpp:25: warning: statement has no effect
C:\C++\Timer\main.cpp:32: error: cannot convert `const wchar_t*' to `const CHAR*' for argument `1' to `BOOL PlaySoundA(const CHAR*, HINSTANCE__*, DWORD)'
C:\C++\Timer\main.cpp:41: warning: statement has no effect
C:\C++\Timer\main.cpp:50: warning: statement has no effect
C:\C++\Timer\main.cpp:56: error: cannot convert `const wchar_t*' to `const CHAR*' for argument `1' to `BOOL PlaySoundA(const CHAR*, HINSTANCE__*, DWORD)'
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 3 warnings
--- End code ---

My Code:

--- Code: ---#include <iostream>
#include <windows.h>
using namespace std;

int main()
{
int Auswahl;
int Zeit;

do
{
cout << "1 für Sekunden" << endl;
cout << "2 für Minuten" << endl;
cout << "3 Hilfe" << endl;
cout << "4 um zu Beenden" << endl;
cin >> Auswahl;
cout << endl;

switch (Auswahl)
{
case (1):
{
cout << "Gib die Zeit in Sekunden ein: ";
cin >> Zeit;
for (Zeit; Zeit > 1; Zeit--)
{
cout << "Noch " << Zeit << " Sekunden" << endl;
Sleep (1000);
}
if (Zeit == 1)
cout << "Noch " << Zeit << " Sekunde" << endl;
PlaySound (L"C:\\WINDOWS\\Media\\notify.wav", NULL, SND_SYNC);
cout << "Zeit ist abgelaufen" << endl << endl;
} break;
case (2):
{
cout << "Gib die Zeit in Minuten ein: ";
cin >> Zeit;
if (Zeit > 1)
{
for (Zeit; Zeit >= 1; Zeit--)
{
cout << "Noch " << Zeit << " Minuten" << endl;
Sleep (60000);
}
}
PlaySound (L"C:\\WINDOWS\\Media\\notify.wav", NULL, SND_SYNC);
cout << "Zeit ist abgelaufen" << endl << endl;
} break;
case (3):
{
cout << "Das ist ein Programm, der die Zeit bis zum Ablaufen der Zeit zählt. Wenn die Zeit abgelaufen ist benachrichtigt das Programm sie mit einem Ton." << endl;
cout << endl;
} break;
default:
cout << "Falsche Eingabe!" << endl;
}
} while (Auswahl != 4);
return 0;
}
--- End code ---

polygon7:

--- Quote from: Marcel on January 25, 2008, 08:46:17 pm ---I Use on Windows Code::Blocks RC2 with the newest nightly build. My Compiler ist MinGW Version 5.1.3. I used a console aplication.

--- Code: ----------------- Build: Debug in Timer ---------------

mingw32-g++.exe -Wall -fexceptions  -g     -c C:\C++\Timer\main.cpp -o obj\Debug\main.o
C:\C++\Timer\main.cpp: In function `int main()':
C:\C++\Timer\main.cpp:25: warning: statement has no effect
C:\C++\Timer\main.cpp:32: error: cannot convert `const wchar_t*' to `const CHAR*' for argument `1' to `BOOL PlaySoundA(const CHAR*, HINSTANCE__*, DWORD)'
C:\C++\Timer\main.cpp:41: warning: statement has no effect
C:\C++\Timer\main.cpp:50: warning: statement has no effect
C:\C++\Timer\main.cpp:56: error: cannot convert `const wchar_t*' to `const CHAR*' for argument `1' to `BOOL PlaySoundA(const CHAR*, HINSTANCE__*, DWORD)'
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 3 warnings
--- End code ---

My Code:

--- Code: ---PlaySound (L"C:\\WINDOWS\\Media\\notify.wav", NULL, SND_SYNC);
PlaySound (L"C:\\WINDOWS\\Media\\notify.wav", NULL, SND_SYNC);

--- End code ---


--- End quote ---

Hi,
remove "L" from all strings in PlaySound (...) calls.

P.S. Also I think that code

--- Code: ---for (Zeit; Zeit > 1; Zeit--)
{
}

--- End code ---
should be something like that

--- Code: ---for (int counter = Zeit; counter > 1; counter--)
{
    cout << counter;
}

--- End code ---

Marcel:
Thanks.

--- Code: ----------------- Build: Debug in Timer ---------------

mingw32-g++.exe -Wall -fexceptions  -g     -c C:\C++\Timer\main.cpp -o obj\Debug\main.o
mingw32-g++.exe  -o bin\Debug\Timer.exe obj\Debug\main.o   
obj\Debug\main.o: In function `main':
C:/C++/Timer/main.cpp:32: undefined reference to `PlaySoundA@12'
C:/C++/Timer/main.cpp:56: undefined reference to `PlaySoundA@12'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
2 errors, 0 warnings
--- End code ---

Do you know what's wrong here?

I removed the L and I changend the fors to

--- Code: ---for (int i = Zeit; i > 1; i--)
--- End code ---

Is it standard to initialize the variables in the loops?

Navigation

[0] Message Index

[#] Next page

Go to full version