- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在没有 FPU 的架构上实现 CORDIC 算法以单精度逼近正弦函数。我将从我的实现中获得的结果与从标准 C 数学函数中获得的结果进行比较。我尝试以两种方式实现:1) 直接使用浮点运算,2) 将输入转换为定点并使用基于整数的运算。我比较了从 sinf()、sin() 和 sin() 转换为 float 获得的结果。比较基于将结果的十六进制表示与数学函数的预期值进行比较。
在 (1) 中,实现使用 double 类型,然后将结果转换为 float。无论使用 CORDIC 进行了多少次迭代,我的计算值总是至少有一个十六进制数字偏差。
在 (2) 中,最初输入被映射到一个 32 位整数。错误与 (1) 中的错误相同。只有在将定点大小增加到 64 位(并将迭代次数增加到 64)之后,精度才会提高。但是,仍然存在算法不精确的输入范围。如果我将定点大小增加到 128 位(迭代次数增加到 128),可能足以获得精确值,但这完全不切实际。
(1)中的算法是书https://www.jjj.de/fxt/fxtbook.pdf的修改版本
#include <math.h>
#include <stdio.h>
const double cordic_1K = 0.6072529350088812561694467525049282631123908521500897724;
double *cordic_ctab;
void make_cordic_ctab(ulong na)
{
double s = 1.0;
for (ulong k=0; k<na; ++k)
{
cordic_ctab[k] = atan(s);
s *= 0.5;
}
}
void cordic(int theta, double* s, double* c, int n)
{
double x, y, z, v;
double tx, ty, tz;
double d;
x = cordic_1K;
y = 0;
z = theta;
v = 1.0;
for (int k = 0; k < n; ++k) {
d = (z >= 0 ? +1 : -1);
tx = x - d * v * y;
ty = y + d * v * x;
tz = z - d * cordic_ctab[k];
x = tx;
y = ty;
z = tz;
v *= 0.5;
}
*c = x;
*s = y;
}
(2)a中的算法是在http://www.dcs.gla.ac.uk/~jhw/cordic/找到的修改版本
#include <math.h>
#include <stdio.h>
#define cordic_1K 0x26dd3b6a10d79600
#define CORDIC_NTAB 64
void cordic(long theta, long *s, long *c, int n) {
long d, tx, ty, tz;
long x = cordic_1K, y = 0, z = theta;
n = (n > CORDIC_NTAB) ? CORDIC_NTAB : n;
for (int k = 0; k < n; ++k) {
d = z >= 0 ? 0 : -1;
tx = x - (((y >> k) ^ d) - d);
ty = y + (((x >> k) ^ d) - d);
tz = z - ((cordic_ctab[k] ^ d) - d);
x = tx;
y = ty;
z = tz;
}
*c = x;
*s = y;
}
CORDIC 表类似地生成,bits=64。
(1) 的测试如下:
int main(int argc, char **argv) {
float angle;
long s, c;
int failed = 0;
cordic_ctab = (double*)malloc(sizeof(double) * 64);
make_cordic_ctab(64);
for (int i = 0; i < step; i++) {
angle = (i / step) * M_PI / 4;
cordic(angle, &s, &c, 64);
float result = s;
float expected = sinf(angle);
if (angle < pow(2, -27))
result = angle;
if (memcmp(&result, &expected, sizeof(float)) != 0) {
failed += 1;
printf("%e : %e\n", result, expected);
printf("0x%x : 0x%x\n", *((unsigned int *)&result),
*((unsigned int *)&expected));
printf("\n");
}
}
printf("failed:%d\n", failed);
}
(2)的测试如下:
int main(int argc, char **argv) {
float angle;
long s, c;
int failed = 0;
double mul = 4611686018427387904.000000;
double step = 1000000000.0;
for (int i = 0; i < step; i++) {
angle = (i / step) * M_PI / 4;
cordic((angle * mul), &s, &c, 64);
float result = s / mul;
float expected = sinf(angle);
if (angle < pow(2, -27))
result = angle;
if (memcmp(&result, &expected, sizeof(float)) != 0) {
failed += 1;
printf("%e : %e\n", result, expected);
printf("0x%x : 0x%x\n", *((unsigned int *)&result),
*((unsigned int *)&expected));
printf("\n");
}
}
printf("failed:%d\n", failed);
}
对于 CORDIC,有什么我没有考虑到的吗?有没有可能CORDIC完全不适合,需要考虑其他方法?
最佳答案
我尝试了一下,但如评论中所述,您不能期望精确的位匹配,因为数学测角通常基于切比雪夫多项式。此外,您还没有定义 cordic_1K
常量。经过一番搜索后,我设法在 C++/VCL 中做到了这一点:
//---------------------------------------------------------------------------
// IEEE 754 single masks
const DWORD _f32_sig =0x80000000; // sign
const DWORD _f32_exp =0x7F800000; // exponent
const DWORD _f32_exp_sig=0x40000000; // exponent sign
const DWORD _f32_exp_bia=0x3F800000; // exponent bias
const DWORD _f32_exp_lsb=0x00800000; // exponent LSB
const DWORD _f32_exp_pos= 23; // exponent LSB bit position
const DWORD _f32_man =0x007FFFFF; // mantisa
const DWORD _f32_man_msb=0x00400000; // mantisa MSB
const DWORD _f32_man_bits= 23; // mantisa bits
const float _f32_lsb = 3.4e-38; // abs min number
//---------------------------------------------------------------------------
float CORDIC32_atan[_f32_man_bits+1];
void f32_sincos(float &s,float &c,float a)
{
int k;
float x,y=0.0,v=1.0,d,tx,ty,ta;
x=0.6072529350088812561694; // cordic_1K
for (k=0;k<=_f32_man_bits;k++)
{
d =(a>=0.0?+1.0:-1.0);
tx=x-d*v*y;
ty=y+d*v*x;
ta=a-d*CORDIC32_atan[k];
x=tx; y=ty; a=ta; v*=0.5;
}
c=x; s=y;
}
//---------------------------------------------------------------------------
double CORDIC64_atan[_f32_man_bits+1];
void f64_sincos(float &s,float &c,double a)
{
int k;
double x,y=0.0,v=1.0,d,tx,ty,ta;
x=0.6072529350088812561694; // cordic_1K
for (k=0;k<=_f32_man_bits;k++)
{
d =(a>=0.0?+1.0:-1.0);
tx=x-d*v*y;
ty=y+d*v*x;
ta=a-d*CORDIC64_atan[k];
x=tx; y=ty; a=ta; v*=0.5;
}
c=x; s=y;
}
//---------------------------------------------------------------------------
//--- Builder: --------------------------------------------------------------
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner):TForm(Owner)
{
int i;
float s0,c0,s1,c1,s2,c2,d32,d64,D32,D64,x;
AnsiString txt="";
// init CORDIC tables
for (x=1.0,i=0;i<=_f32_man_bits;i++,x*=0.5)
{
CORDIC32_atan[i]=atan(x);
CORDIC64_atan[i]=atan(double(x));
}
// 32 bit
D32=0.0; D64=0.0;
for (x=-0.5*M_PI;x<=+0.5*M_PI;x+=0.025)
{
s0=sin(x);
c0=cos(x);
f32_sincos(s1,c1,x); d32=fabs(s1-s0); if (D32<d32) D32=d32;
f64_sincos(s2,c2,x); d64=fabs(s2-s0); if (D64<d64) D64=d64;
if (d32+d64>1e-16)
{
txt+=AnsiString().sprintf("sin(%2.5f) == %2.5f != %2.5f != %2.5f | %.10f %.10f\r\n",x,s0,s1,s2,d32,d64);
f32_sincos(s0,c0,x); // debug breakpoint
f64_sincos(s2,c2,x);
}
}
txt=AnsiString().sprintf("max err: %.10f %.10f\r\n",D32,D64)+txt;
mm_log->Lines->Add(txt);
}
//-------------------------------------------------------------------------
您可以忽略 VCL 之类的东西,例如 AnsiString
(或将其移植到您的环境中),它只是为了打印结果...
代码给了我这个输出:
max err: 0.0000002384 0.0000001192
sin(-1.54580) == -0.99969 != -0.99969 != -0.99969 | 0.0000000596 0.0000000000
sin(-1.52080) == -0.99875 != -0.99875 != -0.99875 | 0.0000001192 0.0000000000
sin(-1.49580) == -0.99719 != -0.99719 != -0.99719 | 0.0000001192 0.0000000000
sin(-1.44580) == -0.99220 != -0.99220 != -0.99220 | 0.0000000596 0.0000000000
sin(-1.42080) == -0.98877 != -0.98877 != -0.98877 | 0.0000000596 0.0000000596
sin(-1.39580) == -0.98473 != -0.98473 != -0.98473 | 0.0000001192 0.0000000596
sin(-1.37080) == -0.98007 != -0.98007 != -0.98007 | 0.0000000000 0.0000000596
sin(-1.34580) == -0.97479 != -0.97479 != -0.97479 | 0.0000000596 0.0000000000
sin(-1.27080) == -0.95534 != -0.95534 != -0.95534 | 0.0000001192 0.0000000000
sin(-1.24580) == -0.94765 != -0.94765 != -0.94765 | 0.0000000596 0.0000000596
sin(-1.22080) == -0.93937 != -0.93937 != -0.93937 | 0.0000000596 0.0000000000
sin(-1.19580) == -0.93051 != -0.93051 != -0.93051 | 0.0000000596 0.0000000596
sin(-1.17080) == -0.92106 != -0.92106 != -0.92106 | 0.0000000596 0.0000000000
sin(-1.14580) == -0.91104 != -0.91104 != -0.91104 | 0.0000001192 0.0000000596
sin(-1.12080) == -0.90045 != -0.90045 != -0.90045 | 0.0000001192 0.0000000000
sin(-1.07080) == -0.87758 != -0.87758 != -0.87758 | 0.0000001788 0.0000000596
sin(-1.04580) == -0.86532 != -0.86532 != -0.86532 | 0.0000001788 0.0000000596
sin(-1.02080) == -0.85252 != -0.85252 != -0.85252 | 0.0000001192 0.0000000596
sin(-0.99580) == -0.83919 != -0.83919 != -0.83919 | 0.0000000000 0.0000000596
sin(-0.97080) == -0.82534 != -0.82534 != -0.82534 | 0.0000001192 0.0000000596
sin(-0.94580) == -0.81096 != -0.81096 != -0.81096 | 0.0000000596 0.0000000596
sin(-0.92080) == -0.79608 != -0.79608 != -0.79608 | 0.0000000000 0.0000000596
sin(-0.89580) == -0.78071 != -0.78071 != -0.78071 | 0.0000001788 0.0000000596
sin(-0.87080) == -0.76484 != -0.76484 != -0.76484 | 0.0000000596 0.0000000000
sin(-0.84580) == -0.74850 != -0.74850 != -0.74850 | 0.0000000596 0.0000000000
sin(-0.82080) == -0.73169 != -0.73169 != -0.73169 | 0.0000001192 0.0000000000
sin(-0.79580) == -0.71442 != -0.71442 != -0.71442 | 0.0000000596 0.0000000000
sin(-0.77080) == -0.69671 != -0.69671 != -0.69671 | 0.0000000596 0.0000000596
sin(-0.74580) == -0.67856 != -0.67856 != -0.67856 | 0.0000000000 0.0000000596
sin(-0.72080) == -0.65998 != -0.65998 != -0.65998 | 0.0000001192 0.0000000596
sin(-0.69580) == -0.64100 != -0.64100 != -0.64100 | 0.0000000596 0.0000000000
sin(-0.67080) == -0.62161 != -0.62161 != -0.62161 | 0.0000001788 0.0000000596
sin(-0.64580) == -0.60184 != -0.60184 != -0.60184 | 0.0000000596 0.0000001192
sin(-0.62080) == -0.58168 != -0.58168 != -0.58168 | 0.0000000596 0.0000001192
sin(-0.59580) == -0.56117 != -0.56117 != -0.56117 | 0.0000000596 0.0000000596
sin(-0.57080) == -0.54030 != -0.54030 != -0.54030 | 0.0000001788 0.0000001192
sin(-0.54580) == -0.51910 != -0.51910 != -0.51910 | 0.0000001788 0.0000001192
sin(-0.52080) == -0.49757 != -0.49757 != -0.49757 | 0.0000000596 0.0000000894
sin(-0.49580) == -0.47573 != -0.47573 != -0.47573 | 0.0000000894 0.0000000596
sin(-0.47080) == -0.45360 != -0.45360 != -0.45360 | 0.0000000894 0.0000000298
sin(-0.44580) == -0.43118 != -0.43118 != -0.43118 | 0.0000000298 0.0000000298
sin(-0.42080) == -0.40849 != -0.40849 != -0.40849 | 0.0000000894 0.0000000596
sin(-0.39580) == -0.38554 != -0.38554 != -0.38554 | 0.0000001192 0.0000000596
sin(-0.37080) == -0.36236 != -0.36236 != -0.36236 | 0.0000000298 0.0000000000
sin(-0.34580) == -0.33895 != -0.33895 != -0.33895 | 0.0000000000 0.0000000298
sin(-0.32080) == -0.31532 != -0.31532 != -0.31532 | 0.0000000596 0.0000000000
sin(-0.29580) == -0.29150 != -0.29150 != -0.29150 | 0.0000000596 0.0000000596
sin(-0.27080) == -0.26750 != -0.26750 != -0.26750 | 0.0000000894 0.0000001192
sin(-0.24580) == -0.24333 != -0.24333 != -0.24333 | 0.0000000894 0.0000001192
sin(-0.22080) == -0.21901 != -0.21901 != -0.21901 | 0.0000000745 0.0000000894
sin(-0.19580) == -0.19455 != -0.19455 != -0.19455 | 0.0000000894 0.0000000596
sin(-0.17080) == -0.16997 != -0.16997 != -0.16997 | 0.0000001043 0.0000000894
sin(-0.14580) == -0.14528 != -0.14528 != -0.14528 | 0.0000000894 0.0000000894
sin(-0.12080) == -0.12050 != -0.12050 != -0.12050 | 0.0000000596 0.0000000671
sin(-0.09580) == -0.09565 != -0.09565 != -0.09565 | 0.0000000522 0.0000000522
sin(-0.07080) == -0.07074 != -0.07074 != -0.07074 | 0.0000000075 0.0000000224
sin(-0.04580) == -0.04578 != -0.04578 != -0.04578 | 0.0000000447 0.0000000335
sin(-0.02080) == -0.02080 != -0.02080 != -0.02080 | 0.0000000596 0.0000000577
sin(0.00420) == 0.00420 != 0.00420 != 0.00420 | 0.0000000545 0.0000000549
sin(0.02920) == 0.02920 != 0.02920 != 0.02920 | 0.0000000447 0.0000000410
sin(0.05420) == 0.05418 != 0.05418 != 0.05418 | 0.0000000149 0.0000000186
sin(0.07920) == 0.07912 != 0.07912 != 0.07912 | 0.0000000224 0.0000000373
sin(0.10420) == 0.10401 != 0.10401 != 0.10401 | 0.0000000820 0.0000000745
sin(0.12920) == 0.12884 != 0.12884 != 0.12884 | 0.0000001043 0.0000000894
sin(0.15420) == 0.15359 != 0.15359 != 0.15359 | 0.0000001043 0.0000001043
sin(0.17920) == 0.17825 != 0.17825 != 0.17825 | 0.0000000447 0.0000000745
sin(0.20420) == 0.20279 != 0.20279 != 0.20279 | 0.0000000596 0.0000000745
sin(0.22920) == 0.22720 != 0.22720 != 0.22720 | 0.0000001043 0.0000001043
sin(0.25420) == 0.25147 != 0.25147 != 0.25147 | 0.0000001192 0.0000000894
sin(0.27920) == 0.27559 != 0.27559 != 0.27559 | 0.0000000000 0.0000000596
sin(0.30420) == 0.29953 != 0.29953 != 0.29953 | 0.0000000596 0.0000000298
sin(0.32920) == 0.32329 != 0.32329 != 0.32329 | 0.0000000596 0.0000000596
sin(0.35420) == 0.34684 != 0.34684 != 0.34684 | 0.0000000298 0.0000000298
sin(0.37920) == 0.37018 != 0.37018 != 0.37018 | 0.0000000298 0.0000000298
sin(0.40420) == 0.39329 != 0.39329 != 0.39329 | 0.0000001788 0.0000000596
sin(0.42920) == 0.41615 != 0.41615 != 0.41615 | 0.0000000894 0.0000000894
sin(0.45420) == 0.43875 != 0.43875 != 0.43875 | 0.0000000298 0.0000000000
sin(0.47920) == 0.46107 != 0.46107 != 0.46107 | 0.0000000596 0.0000000298
sin(0.50420) == 0.48311 != 0.48311 != 0.48311 | 0.0000000596 0.0000000596
sin(0.52920) == 0.50485 != 0.50485 != 0.50485 | 0.0000001788 0.0000000596
sin(0.55420) == 0.52627 != 0.52627 != 0.52627 | 0.0000002384 0.0000001192
sin(0.57920) == 0.54736 != 0.54736 != 0.54736 | 0.0000001192 0.0000000596
sin(0.60420) == 0.56811 != 0.56811 != 0.56811 | 0.0000000596 0.0000000596
sin(0.62920) == 0.58850 != 0.58850 != 0.58850 | 0.0000000596 0.0000001192
sin(0.65420) == 0.60853 != 0.60853 != 0.60853 | 0.0000001192 0.0000001192
sin(0.67920) == 0.62817 != 0.62817 != 0.62817 | 0.0000000596 0.0000001192
sin(0.70420) == 0.64743 != 0.64743 != 0.64743 | 0.0000000596 0.0000000000
sin(0.72920) == 0.66628 != 0.66628 != 0.66628 | 0.0000000596 0.0000000000
sin(0.75420) == 0.68471 != 0.68471 != 0.68471 | 0.0000000596 0.0000000000
sin(0.77920) == 0.70271 != 0.70271 != 0.70271 | 0.0000000596 0.0000000000
sin(0.82920) == 0.73739 != 0.73739 != 0.73739 | 0.0000000596 0.0000000000
sin(0.85420) == 0.75405 != 0.75405 != 0.75405 | 0.0000001192 0.0000000000
sin(0.87920) == 0.77023 != 0.77023 != 0.77023 | 0.0000001192 0.0000000000
sin(0.90420) == 0.78593 != 0.78593 != 0.78593 | 0.0000000596 0.0000000596
sin(0.92920) == 0.80114 != 0.80114 != 0.80114 | 0.0000000596 0.0000001192
sin(0.95420) == 0.81585 != 0.81585 != 0.81585 | 0.0000001788 0.0000000596
sin(0.97920) == 0.83005 != 0.83005 != 0.83005 | 0.0000000000 0.0000000596
sin(1.00420) == 0.84373 != 0.84373 != 0.84373 | 0.0000001788 0.0000000000
sin(1.02920) == 0.85689 != 0.85689 != 0.85689 | 0.0000000596 0.0000000000
sin(1.05420) == 0.86951 != 0.86951 != 0.86951 | 0.0000001192 0.0000000000
sin(1.12920) == 0.90407 != 0.90407 != 0.90407 | 0.0000000596 0.0000000000
sin(1.15420) == 0.91447 != 0.91447 != 0.91447 | 0.0000000596 0.0000000596
sin(1.17920) == 0.92430 != 0.92430 != 0.92430 | 0.0000001788 0.0000000596
sin(1.20420) == 0.93355 != 0.93355 != 0.93355 | 0.0000000596 0.0000000000
sin(1.25420) == 0.95030 != 0.95030 != 0.95030 | 0.0000000596 0.0000000596
sin(1.27920) == 0.95779 != 0.95779 != 0.95779 | 0.0000001192 0.0000000596
sin(1.30420) == 0.96467 != 0.96467 != 0.96467 | 0.0000000596 0.0000000000
sin(1.35420) == 0.97664 != 0.97664 != 0.97663 | 0.0000000596 0.0000000596
sin(1.45420) == 0.99321 != 0.99321 != 0.99321 | 0.0000000596 0.0000000000
sin(1.47920) == 0.99581 != 0.99581 != 0.99581 | 0.0000001192 0.0000000000
sin(1.50420) == 0.99778 != 0.99778 != 0.99778 | 0.0000000596 0.0000000000
sin(1.52920) == 0.99914 != 0.99914 != 0.99914 | 0.0000000596 0.0000000000
sin(1.55420) == 0.99986 != 0.99986 != 0.99986 | 0.0000000596 0.0000000000
如您所见,64 位表与数学 sin
的匹配更好,对于 32 位,误差高达 4 ulp
(2^-24) 和 2 ulp
(2^-24) 用于 64 位表。由于 32 位 float 的尾数是 23+1
位,结果对应尾数的 2 个最低有效位,所以它的最后一个十六进制数字不匹配 ...
PS atan
表是:
CORDIC64_atan[24]={ 0.785398163397448, 0.463647609000806, 0.244978663126864, 0.124354994546761, 0.0624188099959574, 0.0312398334302683, 0.0156237286204768, 0.00781234106010111, 0.00390623013196697, 0.00195312251647882, 0.00097656218955932, 0.000488281211194898, 0.000244140620149362, 0.00012207031189367, 6.10351561742088E-05, 3.05175781155261E-05, 1.52587890613158E-05, 7.62939453110197E-06, 3.8146972656065E-06, 1.90734863281019E-06, 9.53674316405961E-07, 4.76837158203089E-07, 2.38418579101558E-07, 1.19209289550781E-07 };
关于c - 使用 CORDIC 的正弦计算结果不精确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56148283/
#include using namespace std; class C{ private: int value; public: C(){ value = 0;
这个问题已经有答案了: What is the difference between char a[] = ?string?; and char *p = ?string?;? (8 个回答) 已关闭
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 此帖子已于 8 个月
除了调试之外,是否有任何针对 c、c++ 或 c# 的测试工具,其工作原理类似于将独立函数复制粘贴到某个文本框,然后在其他文本框中输入参数? 最佳答案 也许您会考虑单元测试。我推荐你谷歌测试和谷歌模拟
我想在第二台显示器中移动一个窗口 (HWND)。问题是我尝试了很多方法,例如将分辨率加倍或输入负值,但它永远无法将窗口放在我的第二台显示器上。 关于如何在 C/C++/c# 中执行此操作的任何线索 最
我正在寻找 C/C++/C## 中不同类型 DES 的现有实现。我的运行平台是Windows XP/Vista/7。 我正在尝试编写一个 C# 程序,它将使用 DES 算法进行加密和解密。我需要一些实
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
有没有办法强制将另一个 窗口置于顶部? 不是应用程序的窗口,而是另一个已经在系统上运行的窗口。 (Windows, C/C++/C#) 最佳答案 SetWindowPos(that_window_ha
假设您可以在 C/C++ 或 Csharp 之间做出选择,并且您打算在 Windows 和 Linux 服务器上运行同一服务器的多个实例,那么构建套接字服务器应用程序的最明智选择是什么? 最佳答案 如
你们能告诉我它们之间的区别吗? 顺便问一下,有什么叫C++库或C库的吗? 最佳答案 C++ 标准库 和 C 标准库 是 C++ 和 C 标准定义的库,提供给 C++ 和 C 程序使用。那是那些词的共同
下面的测试代码,我将输出信息放在注释中。我使用的是 gcc 4.8.5 和 Centos 7.2。 #include #include class C { public:
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我的客户将使用名为 annoucement 的结构/类与客户通信。我想我会用 C++ 编写服务器。会有很多不同的类继承annoucement。我的问题是通过网络将这些类发送给客户端 我想也许我应该使用
我在 C# 中有以下函数: public Matrix ConcatDescriptors(IList> descriptors) { int cols = descriptors[0].Co
我有一个项目要编写一个函数来对某些数据执行某些操作。我可以用 C/C++ 编写代码,但我不想与雇主共享该函数的代码。相反,我只想让他有权在他自己的代码中调用该函数。是否可以?我想到了这两种方法 - 在
我使用的是编写糟糕的第 3 方 (C/C++) Api。我从托管代码(C++/CLI)中使用它。有时会出现“访问冲突错误”。这使整个应用程序崩溃。我知道我无法处理这些错误[如果指针访问非法内存位置等,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我有一些 C 代码,将使用 P/Invoke 从 C# 调用。我正在尝试为这个 C 函数定义一个 C# 等效项。 SomeData* DoSomething(); struct SomeData {
这个问题已经有答案了: Why are these constructs using pre and post-increment undefined behavior? (14 个回答) 已关闭 6
我是一名优秀的程序员,十分优秀!