Thread: Compiler error error C2065: '_beginthreadex; : undeclared identifier

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    175

    Compiler error error C2065: '_beginthreadex; : undeclared identifier

    I am getting following compiler error when I add followinfg line of code.

    Code:
    hThread = (HANDLE) _beginthreadex(NULL, // Can not be inherited
    							0,	  // Default stack size
    							Sendhello, // Thread start function name
    							(void *)dwSomeData,								// No parameter passed
    							0,				
    							&threadID);
    I have also include process.h file.

    error C2065: '_beginthreadex; : undeclared identifier.

    Please let me know..

    Thanks in advance

  2. #2
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    check your library. Your probably still using the single threaded library. Change to multithread dll or multithread static library.Its under the project options somewhere on msvc.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    175
    Thanks for reply, that solved the problem.

    I have another query. I was referring Windows Multithreded
    application book. In that it is mentioned that it is better to use
    _beginthreadex instead of CreateThread routine to avoid
    disparity.

    Is it really dangerous to use CreateThread?

    When i replaced CreateThread with _beginthreadex, it is giving run time error, saying

    RunTime Error R6016
    Not enough for thread data.

    When I debugged, it is failing in (after few lines of _beginthreadex) function.

    Here is the my call,

    Code:
    	hThread = (HANDLE) _beginthreadex(NULL, // Can not be inherited
    							0,	  // Default stack size
    							Sendhello, // Thread start function name
    							(void *)dwSomeData,								// No parameter passed
    							0,				
    							&threadID);
    Can you please help me

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Ouch! Review the documentation, the parameters list for CreateThread() and beginthreadex() are not the same!

    As for the CreateThread() business, it is certainly true in the past that CreateThread() could create memory leaks if used with certain other routines in the standard library.

    A recent inspection of the headers leads me to suspect that this may no longer be the case, that said, I use beginthread() or beginthreadex() all the time because I am used to doing so. I don't know anybody who uses CreateThread() professionally, people are wary of it, but probably for irrational reasons.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Declared identifier reported as undeclared
    By yougene in forum C Programming
    Replies: 3
    Last Post: 08-22-2006, 09:07 PM
  2. C2025 - Undeclared Identifier 'NULL'
    By INFERNO2K in forum C++ Programming
    Replies: 3
    Last Post: 11-01-2005, 08:01 PM
  3. 'INPUT', undeclared identifier
    By bennyandthejets in forum Windows Programming
    Replies: 4
    Last Post: 08-29-2003, 06:19 AM
  4. Undeclared Identifier Error for SetFilePointerEx
    By Kan in forum C++ Programming
    Replies: 2
    Last Post: 05-05-2003, 02:13 PM
  5. Replies: 5
    Last Post: 02-08-2003, 07:42 PM