User forums > Help
Errors and warnings
JGM:
--- Quote from: Marcel on January 25, 2008, 09:06:40 pm ---Is it standard to initialize the variables in the loops?
--- End quote ---
On C++ is possible, but not on ANSI C
polygon7:
--- Quote from: Marcel on January 25, 2008, 09:06:40 pm ---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?
--- End quote ---
You should add a lib to linker options (but I don't remember which has PlaySound, probably winmm or user32).
Marcel:
winmm.lib. But why is in Code::Blocks the winmm.lib now libwinmm.a? MS VC++ 2005 EE was easier... x)
Jenna:
--- Quote from: Marcel on January 25, 2008, 09:06:40 pm ---Is it standard to initialize the variables in the loops?
--- End quote ---
Not necessarily.
If you want to use the last value of the loop-variable outside the loop (like in your "case (1):", you need to declare the variable outside the loop.
A variable declared in the for-loop's head is only visible inside this loop.
Some very old or broken compilers might ignore that (there might even be a compiler-switch to do so), but it's not standard conform and not reliable.
darthdespotism:
--- Quote from: Marcel on January 25, 2008, 09:32:09 pm ---winmm.lib. But why is in Code::Blocks the winmm.lib now libwinmm.a? MS VC++ 2005 EE was easier... x)
--- End quote ---
You can use MS Toolkit compiler instead of MinGW. I guess there was some #pragma coment() used for Linking which is only supported by VS VC.
In Fact it will be libwinmm.a for MinGW, linked by -lwinmm (gcc adds the lib and .a automatically ;) )
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version