|
-
Oct 4th, 2010, 10:07 AM
#1
Thread Starter
Hyperactive Member
Convert C Macro & Union to VB
I have the below C code I want to convert to VB. How do I convert the macro and union over?
c--------------
#define bf_N 16
#define S(x,i)(bf_S[i][x.w.byte##i])
union aword {
unsigned long word;
unsigned char byte [4];
struct {
unsigned int byte3:8;
unsigned int byte2:8;
unsigned int byte1:8;
unsigned int byte0:8;
} w;
};
vb-------------
Public Const bf_N As Integer = 16
Public Const S(x,i)(bf_S[i][x.w.byte##i])As ???????
-
Oct 4th, 2010, 05:36 PM
#2
Re: Convert C Macro & Union to VB
You could even leave the first #define as a VB #Const:
#Const bf_N = 16
For the second #define macro, there really is no equivalent - turn it into a separate function if possible...
#define S(x,i)(bf_S[i][x.w.byte##i])
The rest translates roughly to the following (I say 'roughly' since there is no equivalent in VB for bit fields):
Code:
Public Structure aword
Public word As UInteger
Public [byte](3) As Byte
Public Structure AnonymousStruct
Public byte3 As UInteger
Public byte2 As UInteger
Public byte1 As UInteger
Public byte0 As UInteger
End Structure
Public w As AnonymousStruct
End Structure
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|