Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what are the alternative for win32 to alarm,bzero,bcopy when porting c code

Tags:

c

winapi

porting

im porting c code to windows 32 bit using visual studio express
now i have 3 functions that i can't find any alternatives in windows
they are:
alarm
bzero
bcopy
what are the equivalent methods in C win32 ?

like image 513
user63898 Avatar asked Aug 16 '10 11:08

user63898


4 Answers

alarm you are going to need to dig for the other two are:

#define bzero(b,len) (memset((b), '\0', (len)), (void) 0)  
#define bcopy(b1,b2,len) (memmove((b2), (b1), (len)), (void) 0)
like image 62
Romain Hippeau Avatar answered Nov 04 '22 13:11

Romain Hippeau


From which platform are you porting to windows? Anyhow bzero and bcopy are depreciated since quite a while.

for bzero:

This function is deprecated (marked as LEGACY in POSIX.1-2001): use memset(3) in new programs. POSIX.1-2008 removes the specifica- tion of bzero().

for bcopy:

This function is deprecated (marked as LEGACY in POSIX.1-2001): use memcpy(3) or memmove(3) in new programs. Note that the first two arguments are interchanged for memcpy(3) and memmove(3). POSIX.1-2008 removes the specification of bcopy().

So just fix your code and use the proposed replacements.

like image 37
Jens Gustedt Avatar answered Nov 04 '22 11:11

Jens Gustedt


memcpy (output, input, size * sizeof (input[0]));

instead of

bcopy (input, output, size * sizeof (input[0]));

And

memset(m, 0, n * sizeof (gfloat));

instead of

bzero (m, n * sizeof (gfloat));
like image 4
seung Avatar answered Nov 04 '22 12:11

seung


for alarm have a look at Win32-API function SetTimer().

like image 2
user411313 Avatar answered Nov 04 '22 13:11

user411313