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 ???????
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