我有 VC++ 代码,但我想将其转换为 C#。我尝试使用不同的软件,但它不会将 VC++ 的某些功能转换为 C#。我该怎么做?或者有什么方法可以直接在 c# 中使用 VC++ 代码?
例如这是 VC++ 方法,我想将其转换为 c#
void init_gf (int poly)
{
int m,b,p,v;
// Return storage from previous setup
if (log)
{
free (log);
free (alog);
free (rspoly);
rspoly = NULL;
}
// Find the top bit, and hence the symbol size
for (b = 1, m = 0; b <= poly; b <<= 1)
m++;
b >>= 1;
m--;
gfpoly = poly;
symsize = m;
// Calculate the log/alog tables
logmod = (1 << m) - 1;
log = (int *) malloc (sizeof (int) * (logmod + 1));
alog = (int *) malloc (sizeof (int) * logmod);
for (p = 1, v = 0; v < logmod; v++)
{
alog[v] = p;
log[p] = v;
p <<= 1;
if (p & b)
p ^= poly;
}
}