0303 dos 控制台 beginthreadex waveinout
首先是头文件问题:
syntax error : missing \’;\’ before identifier \’MMVERSION\’
跟着进去一看
#ifdef _WIN32
typedef UINT MMVERSION; /* major (high byte), minor (low byte) */
然后我就自作聪明加上DEFINE,结果仍然不行,看看MSDN
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Mmsystem.h; include Windows.h.
Library: Use Winmm.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode
加上,OK
#include <windows.h>
然后就是这个函数
error C2065: \’_beginthreadex\’ : undeclared identifier
看看定义:也OK
_CRTIMP unsigned long __cdecl _beginthreadex(void *, unsigned,
unsigned (__stdcall *) (void *), void *, unsigned, unsigned *);
刚开始还以为是DOS控制台程序不能多线程,后来想想还是在WINDOWS 下面,应该没有问题的
应该是多线程设置问题
vc project/settings 把默认命令行“/MLd”修改为:“/MTd”
c/c++ === code genneration === use run-time libary == debug multithreaded dll
Project->Settings->click C/C++ tab,
在Category 中选Code Generation, 然后在Use run-time libray 中选一个
Multithread 配置
To use _beginthread or _beginthreadex,
the application must link with one of the multithreaded C run-time libraries.
project->setting->c/c++标签->选code generation->选multithreaded dll
Q:Why do I get an unresolved external (LNK2001) error on _beginthreadex and _endthreadex? (top)
A:This happens when you compile a project that uses MFC, but your compiler settings are set to use the single-threaded version of the C runtime library (CRT). Since MFC uses threads, it requires the multithreaded CRT. Since the single-threaded CRT doesn\’t contain _beginthreadex() and _endthreadex(), you get a linker error on those two functions.
To change your CRT setting, click Project->Settings and go to the C/C++ tab. Set the Category combo box to Code Generation. In the Use run-time library combo box, chose one of the multithreaded versions of the CRT. For debug builds, choose Debug Multithreaded or Debug Multithreaded DLL. For release builds, choose Multithreaded or Multithreaded DLL. The versions that say "DLL" use MSVCRT.DLL, while the others do not depend on that DLL.
结果可以调试了,但是总是刚刚进入断点就整个程序退出了,迷糊了一下,马上加上
WHILE(1);
OK
error C2065: \’printf\’ : undeclared identifier
历史博文
- 20081028 c# BackgroundWorker - 2009
- 20071009 Response ThreadAbortException - 2008
- 20070125 Comodo Firewall pcaudit 2 DLL injection - 2007
- TortoiseCVS User's Guide翻译2TCVS简介3从何开始 - 2005
- SGIP和CMPP的差别消息头格式认证格式 - 2005
- 来自不同的GOOGLE访问 - 2005
- MAGIC C++ PRO*C编程失败的尝试2 - 2005