473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how to write macro to replace _beginthreadex

bajajv
152 100+
Hi,
there is an example by Jeffrey Richter where he has replaced _beginthreadex by his own macro.
I tried that, but it is giving error.
Here is the code-
Expand|Select|Wrap|Line Numbers
  1. typedef unsigned (__stdcall *PTHREAD_FUNC) (void*);
  2. #define chBeginThreadEx (psa, cbStack, pfnStartAddr,\ pvParam, fdwCreate, pdwThreadId)\
  3. ((HANDLE) _beginthreadex\
  4. ((void*) (psa),\
  5.   (unsigned) (cbStack),\
  6.   (PTHREAD_FUNC) (pfnStartAddr),\
  7.   (void*) (pvParam),\
  8.   (unsigned) (fdwCreate),\
  9.   (unsigned*) (pdwThreadId)\
  10.   )\
  11. )
  12.  
These are the errors-
line 5 - error C2062: type 'unsigned int' unexpected
line 10 - error C2059: syntax error : ')'
line 11 - error C2059: syntax error : ')'

Thanks for your time.
Cheers.
Jan 14 '12 #1
1 2137
donbock
2,426 Expert 2GB
What is the function prototype for _beginthreadex?

I don't know that it will cause any problems, but you don't want that backslash between pfnStartAddr and pvParam. Backslash should only be used to escape newlines.

line 5,8,9: replace (unsigned) with (unsigned int).

I don't know if this is really a problem, but you want to make sure that those backslashes immediately precede newline. Right now it looks like they precede a space.

Does your compiler support inline functions? I might well be better to implement this as an inline function than as a macro.
Jan 14 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Xah Lee | last post by:
suppose you want to do find & replace of string of all files in a directory. here's the code: ©# -*- coding: utf-8 -*- ©# Python © ©import os,sys © ©mydir= '/Users/t/web'
2
by: Roland Hall | last post by:
I have a little test that replaces the same character with two different values. Currently I have to process it twice. Is it possible to do it all at once? dim a, z a = "a,b,c" z =...
2
by: Edgar | last post by:
I want to go from viewing a form (record number "x") to the same record ("x") in a report. Of course, when I open the report, it opens to the first record, not record "x". I don't know VBA,...
4
by: Vittal | last post by:
Hello All, Here is a small C program, main() { int a= 100; float b =99.99; TEST(a,%d); TEST(b,%f);
4
by: Greg -- | last post by:
Is it possible to replace html codes, such as $#63;, to the ASCII equivalent with RegEx? Using RegEx, I'm able to obtain the 63, but I'm unable to convert it: Regex.Replace("?", "&#(.+?);",...
5
by: Casey | last post by:
Hello, Can someone give me specific code to replace text on a page using server side javascript? I need to use server-side because I need the output to be recognized in the final HTML so that...
6
by: DataSmash | last post by:
Hello, I need to search and replace 4 words in a text file. Below is my attempt at it, but this code appends a copy of the text file within itself 4 times. Can someone help me out. Thanks! #...
3
by: TOXiC | last post by:
Hi everyone, First I say that I serched and tryed everything but I cannot figure out how I can do it. I want to open a a file (not necessary a txt) and find and replace a string. I can do it...
3
by: deve8ore | last post by:
Hello, I have built a macro to automatically go to a specific directory and a specific folder, however the names of the files I need to automatically locate change names every month. I.e. - I...
2
by: deve8ore | last post by:
Hello, I receive a workbook via 3rd party containing graphs within each sheet. The workbook may contain a different number of sheets per file. I would like to write a macro to go through each...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.