开发者

Array of THREADENTRY32 struct as function parameter causes C2061

开发者 https://www.devze.com 2023-03-09 06:46 出处:网络
I want to add a method to my debugger which fills a THREADENTRY32 array with all threads of the process being currently debugged. For that, I want to use the method \"EnumerateThreads\" which I pass a

I want to add a method to my debugger which fills a THREADENTRY32 array with all threads of the process being currently debugged. For that, I want to use the method "EnumerateThreads" which I pass a THREADENTRY32 pointer which the function should fill out.

However, I'm having trouble using a THREADENTRY32 po开发者_JS百科inter as a function parameter.

Everytime I declare a function like this in my header file I receive an C2061 error ("syntax error : identifier 'THREADENTRY32'"):

void EnumerateThreads(THREADENTRY32 *threadArray);

The header file includes already which defines the THREADENTRY32 structure if I read that correctly.

Using a custom struct and passing it to the function works without any problems:

struct Test { int bla; DWORD boo; }; [...] void EnumerateThreads(Test *test);

I've worked with int-/char-/float-/etc. arrays, but I don't have any experience with struct arrays. I just wondered why it does work with my own structs but not with the THREADENTRY32 one.


try using:

void EnumerateThreads(struct THREADENTRY32 *threadArray);

this will inline forward declare the struct, however, you need the full definition from Tlhelp32.h where ever you access the members of the struct or use the sizeof operator.

alternatively you need to declare the struct (by including the Tlhelp32.h) in the same translation unit (but preceding) of the proto and its uses, or provide a forward declaration for the compiler to bind to via struct THREADENTRY32;

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号